【问题标题】:Calling an endpoint with a soap payload使用肥皂负载调用端点
【发布时间】:2021-03-04 16:15:39
【问题描述】:

我需要使用 WSO2 ESB 转换一条消息,并完全按照它的格式发送它。我正在接收 xml 格式的有效负载,我需要使用肥皂信封将其转换为 xml。为此,我使用有效负载工厂来转换有效负载:

    <payloadFactory media-type="xml">
        <format>
            <soapenv:Envelope xmlns:param="urn:www.my_url.com/param:1.6" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                <soapenv:Header/>
                <soapenv:Body>
                    <param:GetUser>
                        <GetNameQue>
                            <firstname>$1</firstname>
                            <surname>$2</surname>
                        </GetNameQue>
                    </param:GetUser>
                </soapenv:Body>
            </soapenv:Envelope>
        </format>
        <args>
            <arg evaluator="xml" expression="//MessageGetUser/FirstName"/>
            <arg evaluator="xml" expression="//MessageGetUser/Surname"/>
        </args>
    </payloadFactory>

然后我使用以下方式调用另一个平台:

<property name="messageType" scope="axis2" type="STRING" value="application/xml"/>
    <call>
        <endpoint>
            <http method="post" uri-template="{uri.var.httpendpointurl}">
                <suspendOnFailure>
                    <initialDuration>-1</initialDuration>
                    <progressionFactor>1</progressionFactor>
                </suspendOnFailure>
                <markForSuspension>
                    <retriesBeforeSuspension>0</retriesBeforeSuspension>
                </markForSuspension>
            </http>
        </endpoint>
    </call>

我收到了格式错误的错误消息,经过一些调试后,我发现我的 $body/ 已发送,看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <param:GetUser xmlns:param="urn:www.my_url.com/param:1.6">
      <GetNameQue xmlns="http://ws.apache.org/ns/synapse">
         <firstname>MyFirst</firstname>
         <surname>MySecond</surname>
      </GetNameQue>
   </param:GetUser>
</soapenv:Body>

虽然我的 $env 看起来正是它需要发送的内容:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:param="urn:www.my_url.com/param:1.6">
   <soapenv:Body>
      <param:GetUser>
         <GetNameQue xmlns="http://ws.apache.org/ns/synapse">
         <firstname>MyFirst</firstname>
         <surname>MySecond</surname>
         </GetNameQue>
      </param:GetUser>
   </soapenv:Body>
</soapenv:Envelope>

我的问题是有一种方法可以发送信封而不是正文,或者使用呼叫发送的具体内容是什么?例如,我知道当前的 json ($) 是发送 json 有效负载时发送的那个。

如果我的问题听起来很糟糕,我很抱歉,到目前为止,我还没有找到任何对我有帮助的信息。 编辑:我尝试了以下解决方案,但没有奏效: WSO2 ESB Payload Factory creates invalid SOAP envelope https://isuruuy.medium.com/how-to-construct-a-payload-with-the-soap-envelope-ce8df5032dda https://medium.com/wso2-learning/wso2-esb-ei-apim-create-payloads-with-soap-envelope-481bc0dbf330

如果您需要任何其他信息,请告诉我,我很乐意提供。

提前谢谢大家!

【问题讨论】:

    标签: soap wso2 wso2esb wso2ei


    【解决方案1】:

    为我的通话添加格式会正确发送信封:

    <call>
        <endpoint>
            <http method="post" uri-template="{uri.var.httpendpointurl}" format="soap11">
                <suspendOnFailure>
                    <initialDuration>-1</initialDuration>
                    <progressionFactor>1</progressionFactor>
                </suspendOnFailure>
                <markForSuspension>
                    <retriesBeforeSuspension>0</retriesBeforeSuspension>
                </markForSuspension>
            </http>
        </endpoint>
    </call>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-08-11
      • 2021-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-22
      • 2016-12-04
      相关资源
      最近更新 更多