I have built a proxy service with WSO2 ESB and i want to use it to expose a REST webservice (from some random vendor) as a SOAP webservice to another random vendor. The issue that im having trouble with is that one of the soap methods simply didnt worked. The method in question is "myVendorBpmInsereCliente". What i find really confusing is that the method "myVendorBpmAtualizaCliente" which is pretty much the same thing does work! Im getting error code 405 (http reponse code) because the property mediator "REST_URL_POSTFIX" doesnt seem to append the rest of the path to the uri.
The sequence:
<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>
This is what i got from 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_
During another attempt, i added a custom log mediator to log the value of the expression: $axis2:REST_URL_POSTFIX and the result was what i expected: "cliente/novo?chave=myKey". Note that i changed the endpoint in the sequence for ilustrative purposes. Im using WSO2 ESB Version 4.6.0, running as a service. Any sugestions?