【发布时间】:2017-10-04 19:01:37
【问题描述】:
我正在尝试使用 Ballerina 和 http:ClientConnector 调用 SOAP WS,如何将 Body 和参数传递给 POST 方法?
【问题讨论】:
标签: ballerina
我正在尝试使用 Ballerina 和 http:ClientConnector 调用 SOAP WS,如何将 Body 和参数传递给 POST 方法?
【问题讨论】:
标签: ballerina
请参考sample code of 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);
【讨论】:
xml i1 = soap:constructSoapRequest(payload, namespace, headers); 但我收到错误:httpsample.bal:14: undefined function 'soap:constructSoapRequest' 注意:我导入以下内容:import ballerina.lang.system;导入ballerina.net.http;导入 org.wso2.ballerina.connectors.soap;