Node.js 使用节点JS调用soapweb服务
我是nodejs新手,尝试使用它的soap特性进行soapweb服务调用。我在网上看到了各种各样的例子,但我不知道如何用我掌握的数据来使用它们 我从我的Java应用程序获得了soap请求,并在SoapUI应用程序中使用它,它工作得非常好。只使用了wsdl链接和XML。我需要一个关于如何使用nodejs的例子。提前谢谢 以下是我在SoapUI应用程序中使用的详细信息- WSDL- xml-Node.js 使用节点JS调用soapweb服务,node.js,web-services,soap,Node.js,Web Services,Soap,我是nodejs新手,尝试使用它的soap特性进行soapweb服务调用。我在网上看到了各种各样的例子,但我不知道如何用我掌握的数据来使用它们 我从我的Java应用程序获得了soap请求,并在SoapUI应用程序中使用它,它工作得非常好。只使用了wsdl链接和XML。我需要一个关于如何使用nodejs的例子。提前谢谢 以下是我在SoapUI应用程序中使用的详细信息- WSDL- xml- <?xml version="1.0" encoding="UTF-8"?> <soape
<?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>
*****
*****
*****
*****
Java Axis WSS4J
1.4/1.5.1
Windows NT(未知)/6.2/Sun微系统公司/1.6.0\u 20
第二街
测试
艾尔
12345
美国
2650
1.
*****
*****
*****
您可以使用下面的示例,只需使用正确的SOAPAction
(从您的wsdl来看,它是runTransaction
)
我通常使用创建虚拟示例请求,并在需要时获取正确的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)
})
const request=require('request'))
常量xml=''
常量选项={
正文:xml,
标题:{
“内容类型”:“text/xml;charset=utf-8”,
SOAPAction:'runTransaction'
}
}
常量url=https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.141.wsdl'
const body=request.post(url、选项、(错误、响应)=>{
console.log('response',response.body)
})
非常感谢,效果很好。我想知道如果我在vpn中测试代理信息,是否有一种方法可以传递代理信息?@pragyandiptatripath您可以使用环境变量,这些变量受请求
的尊重:HTTP\u proxy
,HTTPS\u proxy
,无代理
或将代理
添加到选项中