简体   繁体   English

SOAP 请求在 SoapUI 中有效,但在 Node.js 中无效

[英]SOAP request works in SoapUI but doesn't work in Node.js

I am trying to reach a SOAP API using Node.我正在尝试使用 Node.js 访问 SOAP API。

Using SoapUI I can reach it without a problem, and this is the request:使用 SoapUI 我可以毫无问题地访问它,这是请求:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:axis="http://ws.apache.org/axis2">
   <soap:Header/>
   <soap:Body>
      <axis:getKey>
         <!--Optional:-->
         <axis:user>email@email.com</axis:user>
         <!--Optional:-->
         <axis:password>password</axis:password>
      </axis:getKey>
   </soap:Body>
</soap:Envelope>    

However, using the soap package, an error is thrown every single time: Cannot parse response.但是,使用soap包,每次都会抛出错误:无法解析响应。

The XML of the request, however, is pretty much the same:但是,请求的 XML 几乎相同:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns="http://ws.apache.org/axis2" xmlns:ax21="http://rpc.xml.coldfusion/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ax22="http://rpc.xml.coldfusion/xsd">
   <soap:Body>
      <ns:getKey xmlns="http://ws.apache.org/axis2">
         <ns:user>email@email.com</ns:user>
         <ns:password>password</ns:password>
      </ns:getKey>
   </soap:Body>
</soap:Envelope>

I tried it in SoapUI and it's working perfectly!我在 SoapUI 中尝试过,它运行良好! I don't understand why I am getting the error!我不明白为什么我收到错误!

This is my code:这是我的代码:

async method(userData) {
    const wsdl = 'http://www.maxbounty.com/api.cfc?wsdl';
    const client = await soap.createClientAsync(wsdl);
    const test = await client.getKeyAsync({ user: userData.username, password: userData.password });
}

Any idea?任何的想法?

I realised that SoapUI formatted the body in a different way.我意识到 SoapUI 以不同的方式格式化主体。 I copy-pasted the body it was using on my code, and it worked like a charm.我复制粘贴了它在我的代码中使用的主体,它就像一个魅力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM