我试图调用一个在我的SOAP服务中创建的简单方法,该方法返回“ Hello,World!”。我已经能够使用SoapUI成功调用此方法,所以我知道它可以工作。
当前,所有要打印的内容都是一个空对象。我碰壁了,不确定我做错了什么。任何帮助都会很棒!
这就是我所拥有的:
"use strict";
var soap = require('strong-soap').soap;
// wsdl of the web service this client is going to invoke. For local wsdl you can use, url = './wsdls/stockquote.wsdl'
var url = 'https://test-idv.dataventures.com/CP3_WCF_DATA/WCFAccess.svc/mex?wsdl';
var options = {};
soap.createClient(url, options, function (err, client) {
client.addSoapHeader("<wsa:Action>http://tempuri.org/IWCFAccess/GetOtherData</wsa:Action>");
client.addSoapHeader("<wsa:To>https://test-idv.dataventures.com/CP3_WCF_DATA/WCFAccess.svc</wsa:To>");
client.GetOtherData({}, function (err, result, envelope, soapHeader) {
if (err) {
throw err;
}
console.log(result);
// Result is a javascript object
// Envelope is the response envelope from the Web Service
// soapHeader is the response soap header as a JavaScript object
})
});
这是SoapUI XML:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
<soap:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Action>http://tempuri.org/IWCFAccess/GetOtherData</wsa:Action>
<wsa:To>https://test-idv.dataventures.com/CP3_WCF_DATA/WCFAccess.svc</wsa:To>
</soap:Header>
<soap:Body>
<tem:GetOtherData/>
</soap:Body>
</soap:Envelope>
这是Strong-Soap的xml请求
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header>
<wsa:Action>http://tempuri.org/IWCFAccess/GetOtherData</wsa:Action>
<wsa:To>https://test-idv.dataventures.com/CP3_WCF_DATA/WCFAccess.svc</wsa:To>
</soap:Header>
<soap:Body>
<ns1:GetOtherData xmlns:ns1="http://tempuri.org/"/>
</soap:Body>
</soap:Envelope>
答案 0 :(得分:1)
您可以像这样在strong-soap
中添加标头...可能有一种更好的方法来添加xmlns
。
"use strict";
require('request').debug = true
var soap = require('strong-soap').soap;
// wsdl of the web service this client is going to invoke. For local wsdl you can use, url = './wsdls/stockquote.wsdl'
var url = 'https://test-idv.dataventures.com/CP3_WCF_DATA/WCFAccess.svc/mex?wsdl';
var options = {};
soap.createClient(url, options, function (err, client) {
client.addSoapHeader(`<wsa:Action xmlns:wsa="http://www.w3.org/2005/08/addressing">http://tempuri.org/IWCFAccess/GetOtherData</wsa:Action>`);
client.addSoapHeader(`<wsa:To xmlns:wsa="http://www.w3.org/2005/08/addressing">https://test-idv.dataventures.com/CP3_WCF_DATA/WCFAccess.svc</wsa:To>`);
client.GetOtherData({}, function (err, result, envelope, soapHeader) {
console.log('result',result);
console.log('envelope',envelope);
if (err) {
throw err;
}
console.log(result);
})
});