【问题标题】:How can I invoke a SOAP-XML WS with Ballerina如何使用 Ballerina 调用 SOAP-XML WS
【发布时间】:2017-10-04 19:01:37
【问题描述】:

我正在尝试使用 Ballerina 和 http:ClientConnector 调用 SOAP WS,如何将 Body 和参数传递给 POST 方法?

【问题讨论】:

    标签: ballerina


    【解决方案1】:

    请参考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);
    

    【讨论】:

    • 您好 Tharik,感谢您的回复。我正在尝试使用 de soap 连接器设置命名空间、标头和有效负载,然后我使用: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;
    • 您能否确认参数类型符合特定函数的预期
    猜你喜欢
    • 2021-11-06
    • 1970-01-01
    • 2014-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-20
    • 2020-12-16
    相关资源
    最近更新 更多