我是nodejs的新手,并尝试使用它的soap功能来进行soap web服务调用。我在网上看到了各种例子,但无法弄清楚如何将它们与我拥有的数据一起使用。
我从我的Java应用程序获得了soap请求并在SoapUI应用程序中使用它,它工作得很好。刚刚使用了wsdl链接和XML。我需要一个关于如何在nodejs中使用它们的示例。提前谢谢。
以下是我在SoapUI app中使用的详细信息 -
WSDL - https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.141.wsdl
xml -
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-*****">
<wsse:Username>*****</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">*****</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<requestMessage xmlns="urn:schemas-cybersource-com:transaction-data-1.84">
<merchantID>*****</merchantID>
<merchantReferenceCode>*****</merchantReferenceCode>
<clientLibrary>Java Axis WSS4J</clientLibrary>
<clientLibraryVersion>1.4/1.5.1</clientLibraryVersion>
<clientEnvironment>Windows NT (unknown)/6.2/Sun Microsystems Inc./1.6.0_20</clientEnvironment>
<billTo>
<street1>2nd Street</street1>
<city>test</city>
<state>AL</state>
<postalCode>12345</postalCode>
<country>US</country>
</billTo>
<item id="0">
<unitPrice>2650.0</unitPrice>
<quantity>1</quantity>
<productCode>*****</productCode>
<productName>*****</productName>
<productSKU>*****</productSKU>
</item>
<taxService run="true">
<sellerRegistration />
</taxService>
</requestMessage>
</soapenv:Body>
</soapenv:Envelope>
答案 0 :(得分:1)
您可以使用request如下例所示,只需使用正确的SOAPAction
(来自您的wsdl,它的runTransaction
)
我通常使用Boomerang创建虚拟样本请求,并在需要时获取正确的SOAPAction和其他标头。
const request = require('request')
const xml = '<yourxml>'
const opts = {
body: xml,
headers: {
'Content-Type': 'text/xml; charset=utf-8',
SOAPAction: 'runTransaction'
}
}
const url = 'https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.141.wsdl'
const body = request.post(url, opts, (err, response) => {
console.log('response', response.body)
})