- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我正在努力做到这一点:
POST /oms/order.asmx HTTP/1.1
Host:myserver.com
Content-Type: text/xml;
charset=utf-8
Content-Length: length
SOAPAction: "http://shipping_software/AddOrder"
这样做:
var newOrder = buildOrder(orderInfo);
var soapOptions = {
uri: '/oms/order.asmx',
headers: {
'Content-Type': 'text/xml',
'charset': 'utf-8',
'Content-Length': newOrder.length.toString(),
'SOAPAction': 'http://shipping_software/AddOrder',
'Host': 'myserver.com',
'Connection': 'keep-alive'
},
method: 'POST',
body: newOrder //New order is properly formed xml as a String
}
request(soapOptions, function(err, response) {
console.log(err);
console.log(response);
})
// console.log(newOrder);
});
这当前返回“无效的 uri”,当我将 URI 更改为 http://myserver.com/oms/order.asmx
时,我仍然收到 400 响应代码。
编辑: 我将内容类型固定在一行中 Content-Type: text/html; charset=utf-8
没有任何改进。
Edit2:我正在使用 XMLBuilder 构建我的 XML 数据并尝试提交它而不将其转换为字符串,但是来自 SOAP API 的连接超时。
Edit3:完整 SOAP 请求:
POST /oms/order.asmx HTTP/1.1
Host: myserver.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://oms/AddOrder"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<AuthenticationHeader xmlns="http://sma-promail/">
<Username>string</Username>
<Password>string</Password>
</AuthenticationHeader>
<DebugHeader xmlns="http://sma-promail/">
<Debug>boolean</Debug>
<Request>string</Request>
</DebugHeader>
</soap:Header>
<soap:Body>
<AddOrder xmlns="http://sma-promail/">
<order>
<Header>
<ID>string</ID>
<EntryDate>dateTime</EntryDate>
<OrderEntryView>
<SeqID>int</SeqID>
<Description>string</Description>
</OrderEntryView>
<ReferenceNumber>string</ReferenceNumber>
<PONumber>string</PONumber>
<Comments>string</Comments>
<IpAddress>string</IpAddress>
<ApprovalComment>string</ApprovalComment>
<InsertDate>dateTime</InsertDate>
</Header>
<Classification>
<CampaignID>string</CampaignID>
<ResponseMedia>
<Description>string</Description>
</ResponseMedia>
<Source>
<Description>string</Description>
</Source>
<Issue>
<Issue>string</Issue>
</Issue>
<CustomerProject>
<ID>string</ID>
</CustomerProject>
<CustomerCode>string</CustomerCode>
<Store>string</Store>
<Department>string</Department>
<DistributionCenter>string</DistributionCenter>
<Vendor>string</Vendor>
</Classification>
<Shipping>
<FreightCarrier>
<Name>string</Name>
</FreightCarrier>
<FreightService>
<Description>string</Description>
</FreightService>
<FreightAccount>
<SeqID>int</SeqID>
<Description>string</Description>
<FreightCarrier xsi:nil="true" />
<Person xsi:nil="true" />
<ThirdAcctNo>string</ThirdAcctNo>
<NonResident>boolean</NonResident>
</FreightAccount>
<ShippingOption>
<Description>string</Description>
</ShippingOption>
<FreightCode>string</FreightCode>
<FreightCodeDescription>string</FreightCodeDescription>
<ShipComments>string</ShipComments>
<NeededBy>string</NeededBy>
<Rush>boolean</Rush>
<ReleaseDate>dateTime</ReleaseDate>
<ThirdPartyType>int</ThirdPartyType>
<ThirdAccountNumber>string</ThirdAccountNumber>
<NCShip>boolean</NCShip>
<NCPack>boolean</NCPack>
<NCOffers>boolean</NCOffers>
<NCHandling>boolean</NCHandling>
<NCOffShipHandling>boolean</NCOffShipHandling>
<NCSpecialHandling>boolean</NCSpecialHandling>
<NCRush>boolean</NCRush>
</Shipping>
<Money>
<PriceClass>
<SeqID>int</SeqID>
<Description>string</Description>
</PriceClass>
<ShippingHandlingCharge>decimal</ShippingHandlingCharge>
<RushHandlingCharge>decimal</RushHandlingCharge>
<NoChargeType>
<Description>string</Description>
</NoChargeType>
<DiscountAmount>decimal</DiscountAmount>
<DiscountPercent>float</DiscountPercent>
<DiscountCode>
<ID>string</ID>
<Description>string</Description>
</DiscountCode>
<Coupon>
<Code>string</Code>
</Coupon>
<SpecialHandlingCharge>decimal</SpecialHandlingCharge>
<CreditAmount>decimal</CreditAmount>
<GiftCertificate>
<UID>string</UID>
<Amount>decimal</Amount>
</GiftCertificate>
<GiftCertificateAmount>decimal</GiftCertificateAmount>
<TaxPercent>decimal</TaxPercent>
<NoChargeAmount>decimal</NoChargeAmount>
<TaxAmount>decimal</TaxAmount>
</Money>
<Payment>
<PaymentType>
<Description>string</Description>
<Sequence>int</Sequence>
</PaymentType>
<PaymentAmount>decimal</PaymentAmount>
<CCNumber>string</CCNumber>
<CCExpirationDate>string</CCExpirationDate>
<CSC>string</CSC>
<ARReference>string</ARReference>
</Payment>
<OrderVariables>
<OrderVariable>
<SeqID>int</SeqID>
<VariableField xsi:nil="true" />
<Value>string</Value>
</OrderVariable>
<OrderVariable>
<SeqID>int</SeqID>
<VariableField xsi:nil="true" />
<Value>string</Value>
</OrderVariable>
</OrderVariables>
<OrderedBy>
<ORDOBY>
<SeqID>int</SeqID>
<CustomerID>string</CustomerID>
</ORDOBY>
<FullName>string</FullName>
<FullNameWithSuffix>string</FullNameWithSuffix>
<CityStateZip>string</CityStateZip>
<CityStateZipCountry>string</CityStateZipCountry>
<CompoundAddress>string</CompoundAddress>
</OrderedBy>
<ShipTo>
<OrderShipTo>
<SeqID>int</SeqID>
<Flag>Other or OrderedBy</Flag>
<Key>string</Key>
<NeededBy>string</NeededBy>
<ReleaseDate>dateTime</ReleaseDate>
<Rush>boolean</Rush>
<RushHandling>decimal</RushHandling>
<Comments>string</Comments>
<FreightCarrier xsi:nil="true" />
<FreightService xsi:nil="true" />
<ThirdPartyType>int</ThirdPartyType>
<ThirdPartyAccountNumber>string</ThirdPartyAccountNumber>
<FreightCode>string</FreightCode>
<FreightCodeDescription>string</FreightCodeDescription>
<SpecialHandling xsi:nil="true" />
<SpecialHandlingCharge>decimal</SpecialHandlingCharge>
<ShippingHandlingCharge>decimal</ShippingHandlingCharge>
<FullName>string</FullName>
<FullNameWithSuffix>string</FullNameWithSuffix>
<CityStateZip>string</CityStateZip>
<CityStateZipCountry>string</CityStateZipCountry>
<CompoundAddress>string</CompoundAddress>
<PickPacks xsi:nil="true" />
</OrderShipTo>
<OrderShipTo>
<SeqID>int</SeqID>
<Flag>Other or OrderedBy</Flag>
<Key>string</Key>
<NeededBy>string</NeededBy>
<ReleaseDate>dateTime</ReleaseDate>
<Rush>boolean</Rush>
<RushHandling>decimal</RushHandling>
<Comments>string</Comments>
<FreightCarrier xsi:nil="true" />
<FreightService xsi:nil="true" />
<ThirdPartyType>int</ThirdPartyType>
<ThirdPartyAccountNumber>string</ThirdPartyAccountNumber>
<FreightCode>string</FreightCode>
<FreightCodeDescription>string</FreightCodeDescription>
<SpecialHandling xsi:nil="true" />
<SpecialHandlingCharge>decimal</SpecialHandlingCharge>
<ShippingHandlingCharge>decimal</ShippingHandlingCharge>
<FullName>string</FullName>
<FullNameWithSuffix>string</FullNameWithSuffix>
<CityStateZip>string</CityStateZip>
<CityStateZipCountry>string</CityStateZipCountry>
<CompoundAddress>string</CompoundAddress>
<PickPacks xsi:nil="true" />
</OrderShipTo>
</ShipTo>
<BillTo>
<Flag>Other or OrderedBy or DoNotUse or ShipTo</Flag>
<FullName>string</FullName>
<FullNameWithSuffix>string</FullNameWithSuffix>
<CityStateZip>string</CityStateZip>
<CityStateZipCountry>string</CityStateZipCountry>
<CompoundAddress>string</CompoundAddress>
</BillTo>
<Offers>
<OfferOrdered>
<Offer xsi:nil="true" />
<Quantity>int</Quantity>
<CanceledQuantity>int</CanceledQuantity>
<OrderShipTo xsi:nil="true" />
<OrderShipToKey xsi:nil="true" />
<PriceType>unsignedByte</PriceType>
<UnitPrice>decimal</UnitPrice>
<ShipType>short</ShipType>
<ShippingHandling>decimal</ShippingHandling>
<Discounts>decimal</Discounts>
<DiscountPercent>int</DiscountPercent>
<DocumentID>string</DocumentID>
<SeqID>int</SeqID>
<CloneLine>int</CloneLine>
<Unapproved>boolean</Unapproved>
<ShipToKey>string</ShipToKey>
<FgnOrder>string</FgnOrder>
<Comments>string</Comments>
<RCOrderKey>string</RCOrderKey>
<Recurring>boolean</Recurring>
<LineNumber>int</LineNumber>
<Variables xsi:nil="true" />
<ProductDetails xsi:nil="true" />
</OfferOrdered>
<OfferOrdered>
<Offer xsi:nil="true" />
<Quantity>int</Quantity>
<CanceledQuantity>int</CanceledQuantity>
<OrderShipTo xsi:nil="true" />
<OrderShipToKey xsi:nil="true" />
<PriceType>unsignedByte</PriceType>
<UnitPrice>decimal</UnitPrice>
<ShipType>short</ShipType>
<ShippingHandling>decimal</ShippingHandling>
<Discounts>decimal</Discounts>
<DiscountPercent>int</DiscountPercent>
<DocumentID>string</DocumentID>
<SeqID>int</SeqID>
<CloneLine>int</CloneLine>
<Unapproved>boolean</Unapproved>
<ShipToKey>string</ShipToKey>
<FgnOrder>string</FgnOrder>
<Comments>string</Comments>
<RCOrderKey>string</RCOrderKey>
<Recurring>boolean</Recurring>
<LineNumber>int</LineNumber>
<Variables xsi:nil="true" />
<ProductDetails xsi:nil="true" />
</OfferOrdered>
</Offers>
<OrderRecurrenceSchedule>
<RecurrenceSchedules>
<SeqID>int</SeqID>
<ID>string</ID>
<Description>string</Description>
<Definition>string</Definition>
<DefinitionDetail>string</DefinitionDetail>
<Schedule>EveryXDays or EveryXWeeks or EveryXMonths</Schedule>
<ScheduleCount>int</ScheduleCount>
<Cycle>Rolling or Custom</Cycle>
<StartCycleDate>dateTime</StartCycleDate>
<DaysToJoin>int</DaysToJoin>
<MonthlyRecurrenceType>DayOfMonth or WeekOfMonthAndDayOfWeek</MonthlyRecurrenceType>
<MinimumRecurrences>int</MinimumRecurrences>
<MaximumRecurrences>int</MaximumRecurrences>
<RecurrenceIncrement>int</RecurrenceIncrement>
<AllowInfiniteRecurrence>boolean</AllowInfiniteRecurrence>
<InfiniteTag>string</InfiniteTag>
<DurationTag>string</DurationTag>
<ExpirationDate>dateTime</ExpirationDate>
<NextCycleDate>dateTime</NextCycleDate>
<HasValidCycleDate>boolean</HasValidCycleDate>
<AnyOffer>boolean</AnyOffer>
<RecurrenceScheduleShippingOptions xsi:nil="true" />
</RecurrenceSchedules>
<RecurrenceOfferFlag>boolean</RecurrenceOfferFlag>
<RecurrenceShippingOption>
<Description>string</Description>
</RecurrenceShippingOption>
<RecurrenceSpecialHandlingCharge>decimal</RecurrenceSpecialHandlingCharge>
<NumberRecurrence>int</NumberRecurrence>
</OrderRecurrenceSchedule>
<OrderBudget>
<Person>
<Name xsi:nil="true" />
<CompanyInfo xsi:nil="true" />
<Address xsi:nil="true" />
<ContactInfo xsi:nil="true" />
<BillingInfo xsi:nil="true" />
<Variables xsi:nil="true" />
</Person>
</OrderBudget>
</order>
</AddOrder>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<DebugHeader xmlns="http://sma-promail/">
<Debug>boolean</Debug>
<Request>string</Request>
</DebugHeader>
</soap:Header>
<soap:Body>
<AddOrderResponse xmlns="http://sma-promail/">
<AddOrderResult>
<OrderSeqID>int</OrderSeqID>
<OrderID>string</OrderID>
</AddOrderResult>
</AddOrderResponse>
</soap:Body>
</soap:Envelope>
最佳答案
到目前为止的猜测,但假设所有 header 都已正确设置,突出的一件事是 content-type
header - 您已将类型和字符集拆分为多个键:值对;它应该在一行中:
var newOrder = buildOrder(orderInfo);
var soapOptions = {
uri: 'http://myserver.com/oms/order.asmx',
headers: {
'Content-Type': 'text/xml; charset=utf-8',
'Content-Length': newOrder.length.toString(),
'SOAPAction': 'http://shipping_software/AddOrder',
'Host': 'myserver.com',
'Connection': 'keep-alive'
},
method: 'POST',
body: newOrder //New order is properly formed xml as a String
}
request(soapOptions, function(err, response) {
console.log(err);
console.log(response);
})
// console.log(newOrder);
});
此外,正如您在问题中所述,请确保 uri
是完全限定的 URL,而不仅仅是路径后缀。
关于javascript - 使用 npm 请求向 SOAP api 发送帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32132476/
我正在使用npm v5.3.0。 现在,我想将npm更新到v5.4.1。要执行此操作,请在终端中键入以下内容: npm install -g npm 没有任何错误。但是,当我键入npm -v时,得到的
我已经使用 vue-cli 两个星期了,直到今天一切正常。我在本地建立这个项目。 https://drive.google.com/open?id=0BwGw1zyyKjW7S3RYWXRaX24tQ
有什么方法可以更改或重置全局 npm 注册表。 感谢您的帮助。 最佳答案 在终端中运行以下命令以恢复到默认注册表 npm config set registry https://registry.np
查看 npm 的 documentation , 'i' 是 'install' 的别名,是否有任何情况下最好使用完整的 'npm install'? 最佳答案 两者之间没有具体区别。这只是一个懒惰的
目前,每次将更改推送到 GIT 存储库时,我都会发布新版本的 NPM 包。我的大部分更改只是愚蠢的补丁。我使用 NPM 作为工具,在我的许多项目中启用版本控制和代码重用。经过一个月的工作,我已经完成了
我运行的时候总是报错 npm install 谁知道怎么解决 npm ERR! Darwin 13.0.0 npm ERR! argv "/usr/local/bin/node" "/usr/b
“npm uninstall packageName”删除包并更新 package.json 文件。 但是来自 npm 文档 - To remove a package from the depend
我的背景更熟悉 composer .我收到 gulp (等)进行构建过程和学习 node以及如何使用 npm我走的时候。 很奇怪(再次来自 composer 背景)composer.lock默认情况下
我看到的许多 npm 模块名称前面都添加了技术名称,例如 react-native 或 jquery 等。由于我们已经在 package.json 文件中提供了关键字,因此遵循此约定有什么好处。我问这
我检查了 connect-privkey-to-provider模块在依赖项中。但是,它一直在说 模块 'connect-privkey-to-provider' 是无关的 npm 和 找不到模块 '
我正在进行持续集成并发现了 npm ci命令。 我不知道在我的工作流程中使用此命令有什么优势。 速度更快吗?这会让测试变得更难吗?好吗? 最佳答案 来自the official documentati
我有一个要发布到 NPM 的包,其中还包含如下所示的演示目录: . +-- demo | +-- src | | +-- main.js | +-- package.json +--
如果我打开集成终端并运行 npm -v 它会起作用。 但是,如果我直接从 NPM SCRIPTS 运行它,它就不起作用。 评论中要求的更多详细信息 //由 Fogmeister 编辑 我也有这个问题,
我正在尝试安装 gulp,当我写 npm install 时我得到了这个问题: npm ERR! code 1 npm ERR! path D:\www\wegrow\node_modules\nod
这个问题已经有答案了: npm test --codecoverage doesn't generate report (3 个回答) 已关闭 4 年前。 当我执行npm test --code-co
我能够运行 npm start 和 npm run start 命令。我用过create-react-app创建我的应用程序。为了在 CSS 模块中进行配置更改,我想运行 npmject 但它会抛出错
我正在使用npm run script执行“构建”和“测试”等任务。 例如,我的 package.json 如下所示: { "name": "fulfillment-service", "ve
我第一次将 npm 模块添加到我的项目中(jshint、optimg、jpgo)。我注意到有些项目,当我做 npm 运行 [名称] ,给出“sh: [name]: command not found”
我已经在 Windows 上安装了 Ubuntu Bash。我已经有 nodejs和 npm在我的 Windows 机器上 C:\Program Files\nodejs .在 Windows 的 b
我正在尝试运行 npm install bitgo命令但在终端上出现以下错误, npm ERR! code EMFILE npm ERR! syscall spawn git npm ERR! pat
我是一名优秀的程序员,十分优秀!