WSO2 ESB呼叫未通过信封

时间:2017-03-02 07:33:04

标签: wso2 esb

我有一个

形式的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始终为null。它基本上与将该地址放入浏览器完全省略SOAP信封完全相同,但是记录该调用会按预期将信封打印到控制台,以便生成信封但不会进入应用程序服务器。

我也尝试过的事情:

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

2)使用WSDL端点而不是地址。结果与1中相同。

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

此时我已经厌倦了我对ESB的理解不足。

1 个答案:

答案 0 :(得分:2)

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

<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>
相关问题