Pergunta

I have a proxy which takes incoming XML and preforms an xslt transform on it to get the required xml format. It should then be sent to the service as JSON so i've set the messageType as application/json however it arrives as XML.

<proxy xmlns="http://ws.apache.org/ns/synapse" name="XSLTTRANSPROXY_BRYN" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <xslt key="gov:/Complete.xsl">
            <property xmlns:ns="http://org.apache.synapse/xsd" name="GUID" expression="fn:substring-after(get-property('MessageID'), 'urn:uuid:')"/>
         </xslt>
        <property name="messageType" value="application/json" scope="axis2"/>
         <log level="full"/>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
      <endpoint>
         <address uri="http://localhost:54150/"/>
      </endpoint>
   </target>
   <description></description>
</proxy>

I've tried various types of builders in the axis2.xml file however none seem to change the result. Currently running WSO2 ESB 4.6.0

Foi útil?

Solução

Your Code should be like this:

<proxy xmlns="http://ws.apache.org/ns/synapse" name="XSLTTRANSPROXY_BRYN" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <xslt key="gov:/Complete.xsl">
            <property xmlns:ns="http://org.apache.synapse/xsd" name="GUID" expression="fn:substring-after(get-property('MessageID'), 'urn:uuid:')"/>
         </xslt>
        <property name="messageType" value="application/json" scope="axis2"/>
         <log level="full"/>
<send>
<endpoint>
         <address uri="http://localhost:54150/"/>
      </endpoint>
</send>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
         </target>
   <description></description>
</proxy>

And you need to enable the tags mentioned in this document:- http://docs.wso2.org/wiki/display/ESB403/ESB+and+JSON. If you are not getting data in json try the service in other browser

Outras dicas

Your proxy should work with no issue. When we set,

<property name="messageType" value="application/json" scope="axis2"/>

message will turn into json by message formatter. So if we log before send, its still in xml format. You can see the converted message using a tool like tcpmon.

I tested following sample, pointing to tcpmon.

<proxy name="TestProxy"
          transports="https http"
          startOnLoad="true"
          trace="disable">
      <description/>
      <target>
         <endpoint>
            <address uri="http://localhost:8888/"/>
         </endpoint>
         <inSequence>
            <property name="messageType" value="application/json" scope="axis2"/>
            <log level="full"/>
         </inSequence>
         <outSequence>
            <send/>
         </outSequence>
      </target>
   </proxy>

Please follow the instructions on the following link http://docs.wso2.org/wiki/display/ESB403/ESB+and+JSON

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top