如何在 XML-WSDL 中向 nodejs 中的服务发送请求
How send a request to a service in XML-WSDL in nodejs
我在 Web 服务 (WSDL) 中有一个 XML。该文件包含许多服务,我想在 Nodejs 中向其中一项服务发送请求。但是我对 XML 和 WSDL 一无所知。我只想请求服务并向其发送一些参数并获得响应。
此 xml 服务包含如下服务:
<wsdl:operation name="bpPaymentRequest">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="bpPayRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="bpPayRequestResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
并且我想向此服务请求这样的内容:
const response = await axios.post( "https://example.com/services/pgw?bpPaymentRequest" , payReqParams)
但是如果我测试这个,我知道这是错误的!我应该如何向该服务发送请求?
您似乎愿意从 axios
调用 SOAP
网络服务。
SOAP Web 服务讲座 XML
。这意味着他们接受 XML 作为输入和 return 另一个 XML 作为响应。与Json APIs
相反,它们不接受JSON数据输入。
所以,
- 您需要准备一个XML用于输入
- 通过
axios
发送
- 解析结果假设是有效的 XML
示例代码如下:
var xml ='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"\
xmlns:web="http://shaparak/">\
<soapenv:Header/>\
<soapenv:Body>\
<web:param>\
<web:amount>123</web:amount>\
</web:param>\
</soapenv:Body>\
</soapenv:Envelope>';
axios.post('https://example.com/services/pgw?bpPaymentRequest',
xml,
{headers:
{'Content-Type': 'text/xml'}
}).then(res=>{
console.log(res);
}).catch(err=>{console.log(err)});
关注
您是否正在实施用于使用 Mellat 或 Shaparak 付款的银行网关?他们对 Node.js.
有一些实现
我在 Web 服务 (WSDL) 中有一个 XML。该文件包含许多服务,我想在 Nodejs 中向其中一项服务发送请求。但是我对 XML 和 WSDL 一无所知。我只想请求服务并向其发送一些参数并获得响应。
此 xml 服务包含如下服务:
<wsdl:operation name="bpPaymentRequest">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="bpPayRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="bpPayRequestResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
并且我想向此服务请求这样的内容:
const response = await axios.post( "https://example.com/services/pgw?bpPaymentRequest" , payReqParams)
但是如果我测试这个,我知道这是错误的!我应该如何向该服务发送请求?
您似乎愿意从 axios
调用 SOAP
网络服务。
SOAP Web 服务讲座 XML
。这意味着他们接受 XML 作为输入和 return 另一个 XML 作为响应。与Json APIs
相反,它们不接受JSON数据输入。
所以,
- 您需要准备一个XML用于输入
- 通过
axios
发送
- 解析结果假设是有效的 XML
示例代码如下:
var xml ='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"\
xmlns:web="http://shaparak/">\
<soapenv:Header/>\
<soapenv:Body>\
<web:param>\
<web:amount>123</web:amount>\
</web:param>\
</soapenv:Body>\
</soapenv:Envelope>';
axios.post('https://example.com/services/pgw?bpPaymentRequest',
xml,
{headers:
{'Content-Type': 'text/xml'}
}).then(res=>{
console.log(res);
}).catch(err=>{console.log(err)});
关注
您是否正在实施用于使用 Mellat 或 Shaparak 付款的银行网关?他们对 Node.js.
有一些实现