2017-06-15 60 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] } } }