2017-06-15 59 views
1

我使用node.js soap发送肥皂请求,但我一直在收到错误。如何使用nodejs肥皂创建wsdl soap请求

在了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); 

    }); 
}); 

以下是错误:

一个:InternalServiceFault 坏API金钥

请有人帮我解决这个问题吗?

+0

忘了提,我使用的是ApiKey在SoapUI上工作。 –

回答

0

看来你必须为你的apiKey和orderId使用一个命名空间。你需要在你的soapclient SDK中看到如何设置命名空间

+0

根据github上的文档[链接](https://github.com/vpulim/node-soap#clientmethodargs-callback---call-method-on-the-soap-service)我尝试将名称空间前缀添加到元素名称为acl:ApiKey,acl:OrderId和tem:args。它会给我一个错误,说“acl/tem无法识别”..... –

1

我已经使用强大的肥皂工作。

下面是代码:

"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] } } }