【问题标题】:WSO2 ESB call not passing envelopeWSO2 ESB 调用未通过信封
【发布时间】:2017-03-02 07:33:03
【问题描述】:

我有一个表单的 API

<api xmlns="http://ws.apache.org/ns/synapse" name="MyRestApi" context="/practice">
<resource methods="GET" uri-template="/{someValue}">
    <inSequence>
    <header name="Action" value="urn:sayHello"/>
    <payloadFactory media-type="xml">
        <format>
            <p:sayHello xmlns:p="http://practice">
                <p:inputString>$1</p:inputString>
            </p:sayHello>
        </format>
        <args>
           <arg evaluator="xml" expression="$ctx:uri.var.someValue"/>
        </args>
    </payloadFactory>
    <log level="full"/>
    <call>
        <endpoint>
           <address uri="http://192.168.0.105:9763/services/Practice/sayHello" format="soap12"/>
        </endpoint>
    </call>
    <enrich>
        <source type="body" clone="true"/>
        <target type="property" action="child" property="body_of_first_call"/>
    </enrich>
    <property xmlns:ns="http://practice" name="response" expression="//ns:return" scope="default" type="STRING"/>
    <property xmlns:ns="http://practice" name="response2" expression="//ns:sayHelloResponse" scope="default" type="STRING"/>
    <log>
        <property name="myValue" expression="$ctx:response"/>
        <property name="myValue2" expression="$ctx:response2"/>
        <property name="myValue3" expression="$ctx:body_of_first_call"/>
    </log>
    <payloadFactory media-type="xml">
        <format>
            <result>
                <sentValue>$1</sentValue>
                <returnedValue>$2</returnedValue>
            </result>
        </format>
        <args>
            <arg evaluator="xml" expression="$ctx:uri.var.someValue"/>
            <arg evaluator="xml" expression="$ctx:response"/>
        </args>
    </payloadFactory>
    <property name="messageType" value="application/xml" scope="axis2" type="STRING"/>
    <respond/>
    </inSequence>
    <outSequence/>
    <faultSequence/>
</resource>
</api>

几乎完全基于找到的指南here

此时只是试图掌握连接器和 API 的概念,以便我可以将其应用到我正在做的工作中,但我遇到了障碍。任何与外部 SOAP 服务通信的尝试(我的 ESB 需要这样做)要么无法找到端点,要么无法传递 SOAP 信封中的值。

如上所写,代码会找到端点,但请求中的输入值 inputString 始终为空。它本质上与将该地址放入浏览器中完全省略 SOAP 信封相同,但是记录调用会按预期将信封打印到控制台,因此正在生成信封但不会进入应用程序服务器。

我也尝试过的事情:

1) 将端点地址改为服务端点,而不是具体操作。这会导致来自 AS 的错误,声称无法找到该操作。此端点和操作在 SoapUI 中按预期工作。

2) 使用 WSDL 端点而不是地址。结果和1一样。

3) 添加/删除标题标签。所有三个端点都已尝试使用/不使用标头标签。他们的结果没有改变。

在这一点上,我已经耗尽了我对 ESB 的理解。

【问题讨论】:

    标签: wso2 esb


    【解决方案1】:

    为了调用我的服务,我以这种方式设置了我的中介。

    <call blocking="true">
      <endpoint>
       <address uri="http://169.254.193.10:9769/services/ServicePharmacy" format="soap11"/>
      </endpoint>
    </call>
    

    true 中的阻塞属性是做同步消息传递

    <call blocking="true">
    
    </call>
    

    这是我的 API

    <api xmlns="http://ws.apache.org/ns/synapse" name="showByIdCallMediator" context="/getByIdCall">
       <resource methods="GET" uri-template="/{Id}">
          <inSequence>
             <property name="getId" expression="get-property('uri.var.Id')" scope="default" type="STRING"/>
             <log>
                <property name="ID" expression="get-property('getId')"/>
             </log>
             <payloadFactory media-type="xml">
                <format>
                   <p:searchPharmacy xmlns:p="http://pharmacy.arce.org">
                      <ax22:pharmacy xmlns:ax22="http://pharmacy.arce.org">
                         <xs:id xmlns:xs="http://pharmacy.arce.org/xsd">$1</xs:id>
                      </ax22:pharmacy>
                   </p:searchPharmacy>
                </format>
                <args>
                   <arg evaluator="xml" expression="get-property('getId')"/>
                </args>
             </payloadFactory>         
             <header name="Action" scope="default" value="urn:searchPharmacy"/>         
             <call blocking="true">
                <endpoint>
                   <address uri="http://169.254.193.10:9769/services/ServicePharmacy" format="soap11"/>
                </endpoint>
             </call>
             <log>
                <property xmlns:ns="http://org.apache.synapse/xsd" name="Status" expression="get-property('axis2','HTTP_SC')"/>
             </log>
             <log level="full"/>
             <enrich>
                <source type="body" clone="true"/>
                <target type="property" property="Ouput_Respose_Service"/>
             </enrich>
             <log level="custom" separator=",">
                <property name="Service_Response" expression="get-property('Ouput_Respose_Service')"/>
             </log>
             <respond description=""/>
          </inSequence>
          <outSequence>
             <log level="full"/>
             <send/>
          </outSequence>
          <faultSequence>
             <sequence key="{faultSEQ}"/>
          </faultSequence>
       </resource>
    </api>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多