我正在尝试使用 Ballerina 和 http:ClientConnector 调用 SOAP WS,如何将 Body 和参数传递给 POST 方法?
问问题
391 次
1 回答
0
请参考soapConnector.bal的示例代码(0.93版)
您需要像这样构造请求 XML 有效负载
xml soapRequest = xmls:parse("<soapenv:Envelope xmlns:soapenv=\"" + namespace + "\"></soapenv:Envelope>");
并设置有效负载以及标头以调用端点
message backendServiceReq ={};
string reqType = "application/soap+xml";
string soapDefinition;
soapDefinition, _ = (string) namespaceMap["1.2"];
messages:setXmlPayload(backendServiceReq, soapRequest);
messages:setHeader(backendServiceReq, "Content-Type", reqType);
if (soapAction != "null") {
messages:setHeader(backendServiceReq, "SOAPAction", soapAction);
}
message response = httpConnector.post(url, backendServiceReq);
于 2017-10-06T03:57:11.990 回答