在soap到rest转换期间,来自wso2 esb的意外行为

时间:2015-03-12 19:51:12

标签: web-services rest soap wso2 wso2esb

我已经使用WSO2 ESB构建了代理服务,我想用它将REST Web服务(来自某个随机供应商)作为SOAP Web服务公开给另一个随机供应商。我遇到麻烦的问题是其中一种肥皂方法根本没用。有问题的方法是“myVendorBpmInsereCliente”。我发现真正令人困惑的是,方法“myVendorBpmAtualizaCliente”几乎是一样的工作!我得到错误代码405(http响应代码),因为属性调解器“REST_URL_POSTFIX”似乎没有将其余路径附加到uri。

序列:

<proxy xmlns="http://ws.apache.org/ns/synapse" name="cadastroMyVendor" transports="https,http" statistics="enable" trace="enable" startOnLoad="true">
<target>
    <inSequence>
        <property name="request_action" expression="get-property('Action')"/>
        <switch source="get-property('request_action')">
            <case regex="myVendorBpmConsultaPeriodo">
                <property name="chave" value="myKey" scope="default" type="STRING"/>
                <property name="datainicio" expression="//datainicio" scope="default" type="STRING"/>
                <property name="datafim" expression="//datafim" scope="default" type="STRING"/>
                <property name="queryparams" expression="fn:concat('consulta/periodo?chave=',get-property('chave'))" scope="default" type="STRING"/>
                <property name="queryparams" expression="fn:concat(get-property('queryparams'),'&datainicio=')" scope="default" type="STRING"/>
                <property name="queryparams" expression="fn:concat(get-property('queryparams'),get-property('datainicio'))" scope="default" type="STRING"/>
                <property name="queryparams" expression="fn:concat(get-property('queryparams'),'&datafim=')" scope="default" type="STRING"/>
                <property name="queryparams" expression="fn:concat(get-property('queryparams'),get-property('datafim'))" scope="default" type="STRING"/>
                <property name="REST_URL_POSTFIX" expression="get-property('queryparams')" scope="axis2" type="STRING"/>
                <property name="HTTP_METHOD" value="GET" scope="axis2" type="STRING"/>
                <log level="full"/>
            <case regex="myVendorBpmInsereCliente">
                <property name="chave" value="myKey" scope="default" type="STRING"/>
                <property name="queryparams" expression="fn:concat('cliente/novo?chave=',get-property('chave'))" scope="default" type="STRING"/>
                <property name="REST_URL_POSTFIX" expression="get-property('queryparams')" scope="axis2" type="STRING"/>
                <property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
                <xslt key="conf:/repository/scripts/dropTheSoap.xsl"/>
            </case>
            <case regex="myVendorBpmAtualizaCliente">
                <property name="chave" value="myKey" scope="default" type="STRING"/>
                <property name="queryparams" expression="fn:concat('cliente/atualiza?chave=',get-property('chave'))" scope="default" type="STRING"/>
                <property name="REST_URL_POSTFIX" expression="get-property('queryparams')" scope="axis2" type="STRING"/>
                <property name="HTTP_METHOD" value="PUT" scope="axis2" type="STRING"/>
                <xslt key="conf:/repository/scripts/dropTheSoap.xsl"/>
            </case>
            <default>
                <!-- code omitted -->
            </default>
        </switch>
        <send>
           <endpoint key="gov:/trunk/endpoints/myKey"/>
              <address uri="http://somehost:8080/STL-WS/myVendor/" format="pox"/>
           <endpoint key="gov:/trunk/endpoints/myKey"/>
        </send>
    </inSequence>
    <outSequence>
        <send/>
    </outSequence>
</target>
<description></description>

这是我从wso2-esb-trace得到的:

16:26:51,090 [-] [HttpClientWorker-10] INFO TRACE_LOGGER End : Send mediator 16:26:51,090 [-] [HttpClientWorker-10] INFO TRACE_LOGGER End : Sequence <anonymous> 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Proxy Service cadastro_myVendor received a new message from : 127.0.0.1 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Message To: /services/cadastro_myVendor 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER SOAPAction: myVendorBpmInsereCliente 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER WSA-Action: myVendorBpmInsereCliente 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Using the anonymous in-sequence of the proxy service for mediation 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Start : Sequence <anonymous> 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Sequence <SequenceMediator> :: mediate() 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Start : Property mediator 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Setting property : request_action at scope : default to : myVendorBpmInsereCliente (i.e. result of expression : get-property('Action')) 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER End : Property mediator 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Start : Switch mediator 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER XPath : get-property('request_action') evaluates to : myVendorBpmInsereCliente 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Matching case found : myVendorBpmInsereCliente 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Sequence <AnonymousListMediator> :: mediate() 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Start : Property mediator 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Setting property : chave at scope : default to : myKey (i.e. constant : myKey) 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER End : Property mediator 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Start : Property mediator 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Setting property : queryparams at scope : default to : cliente/novo?chave=myKey (i.e. result of expression : fn:concat('cliente/novo?chave=',get-property('chave'))) 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER End : Property mediator 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Start : Property mediator 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Setting property : REST_URL_POSTFIX at scope : axis2 to : cliente/novo?chave=myKey (i.e. result of expression : get-property('queryparams')) 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER End : Property mediator 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Start : XSLT mediator 16:26:51,324 [-] [HttpServerWorker-15] WARN TRACE_LOGGER Warning encountered during stylesheet parsing : javax.xml.transform.TransformerConfigurationException: The attribute axis starting at an attribute node will never select anything 16:26:51,324 [-] [HttpServerWorker-15] WARN TRACE_LOGGER Warning encountered during stylesheet parsing : javax.xml.transform.TransformerConfigurationException: The child axis starting at an attribute node will never select anything 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER output method: xml; encoding: ISO-8859-1 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Using org.apache.synapse.util.jaxp.StreamSourceBuilder 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Using org.apache.synapse.util.jaxp.StreamResultBuilder 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Transformation completed - processing result 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Replace node with result 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER End : XSLT mediator 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Start : Property mediator 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Setting property : HTTP_METHOD at scope : axis2 to : POST (i.e. constant : POST) 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER End : Property mediator 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Start : Send mediator 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER Sending message through endpoint : gov//trunk/endpoints/myVendor resolving to address = http://somehost:8080/STL-WS/myVendor/ 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER SOAPAction: myVendorBpmInsereCliente 16:26:51,324 [-] [HttpServerWorker-15] INFO TRACE_LOGGER WSA-Action: myVendorBpmInsereCliente 16:26:51,340 [-] [HttpServerWorker-15] INFO TRACE_LOGGER End : Send mediator 16:26:51,340 [-] [HttpServerWorker-15] INFO TRACE_LOGGER End : Sequence <anonymous> 16:26:51,355 [-] [HttpClientWorker-11] INFO TRACE_LOGGER Start : Sequence <anonymous> 16:26:51,355 [-] [HttpClientWorker-11] INFO TRACE_LOGGER Sequence <SequenceMediator> :: mediate() 16:26:51,371 [-] [HttpClientWorker-11] ERROR TRACE_LOGGER Error while building message_

在另一次尝试期间,我添加了一个自定义日志中介来记录表达式的值:$ axis2:REST_URL_POSTFIX,结果是我所期望的:“cliente / novo?chave = myKey”。请注意,我为了ilustrative目的更改了序列中的端点。我使用WSO2 ESB版本4.6.0,作为服务运行。任何sugestions?

1 个答案:

答案 0 :(得分:1)

请您更改端点格式以确定是否可以解决问题。