如何使用nodejs soap创buildwsdl soap请求
我用node.js的肥皂发送肥皂请求,但我不断收到错误。
在SoapUI中,我的xml如下所示:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:acl="http://schemas.datacontract.org/2004/07/Acl.WcfService.Model"> <soapenv:Header/> <soapenv:Body> <tem:GetOrder> <!--Optional:--> <tem:args> <!--Optional:--> <acl:ApiKey></acl:ApiKey> <!--Optional:--> <acl:OrderId></acl:OrderId> </tem:args> </tem:GetOrder> </soapenv:Body> </soapenv:Envelope>
这是我的代码:
var args = { 'args': { 'ApiKey' : '***', 'OrderId' : '***' } }; soap.createClient(wsdlURL, function (err, soapClient) { soapClient.GetOrder(args, function (err, result) { //the result goes here if (err) { console.log(err); return; } console.log(result); }); });
这是错误:
a:InternalServiceFault坏Api密钥
请有人帮我这个?
我已经使用powershell肥皂工作了。
这里是代码:
"use strict"; var soap = require('strong-soap').soap; var url = 'http://acldev.azurewebsites.net/CmsService.svc?singleWsdl'; var requestArgs = { args: { ApiKey : '***', OrderId : '***' } }; var options = {}; soap.createClient(url, options, function(err, client) { var method = client['CmsService']['BasicHttpBinding_ICmsService']['GetOrder']; method(requestArgs, function(err, result, envelope, soapHeader) { //response envelope console.log('Response Envelope: \n' + envelope); //'result' is the response body console.log('Result: \n' + JSON.stringify(result)); }); });
(这是client.describe()的返回值:
{ CmsService: { BasicHttpBinding_ICmsService: { GetOrders: [Object], GetOrder: [Object] }, BasicHttpBinding_ICmsService1: { GetOrders: [Object], GetOrder: [Object] } } }
)
看来你必须为你的apiKey和orderId使用一个命名空间。 你需要在你的soapclient sdk中看到如何设置命名空间