Alex Yakimovich
Alex Yakimovich

Reputation: 269

WSO2 esb: how to proxy REST service with numeric operation name

We are trying to implement basic SOAP-to-REST proxy service on WSO2 ESB. Our 3rd-party REST service accepts the requests in the following format:

http://<MYURL>/simpleQuery/16783484?oslc.select=value1

The problem is that operation name has numeric only format - "16783484" in our case. payloadFactory mediator does not allow having <16783484> as XML element, since XML spec restricts numeric-only element names.

<proxy xmlns="http://ws.apache.org/ns/synapse" name="CQProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <payloadFactory>
            <format>
               <16783484>
                  <oslc.select>$1</oslc.select>
               </16783484>
            </format>
            <args>
               <arg value="myvalue1"/>
            </args>
         </payloadFactory>
         <send>
            <endpoint>
               <address uri="http://<MYURL>/simpleQuery" format="get"/>
            </endpoint>
         </send>
         <drop/>
      </inSequence>
      <outSequence>
         <log level="full"/>
         <send/>
      </outSequence>
   </target>
</proxy>

How can this be overcome?

Appreciate your help!

Upvotes: 0

Views: 1032

Answers (2)

Alex Yakimovich
Alex Yakimovich

Reputation: 269

WSO2 support team suggested the following solution. Thank you Sandapa!

In that case, you have to set endpoint format as 'rest'. And if it's a GET request you have to set 'HTTP_METHOD' as as GET. Please refer the example given below.

Example:

<proxy xmlns="http://ws.apache.org/ns/synapse" name="CQProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <property name="REST_URL_POSTFIX" value="/getSimpleQuote?symbol=IBM" scope="axis2" type="STRING"/>
         <property name="HTTP_METHOD" value="GET" scope="axis2" type="STRING"/>
         <send>
            <endpoint>
               <address uri="http://localhost:9000/services/SimpleStockQuoteService/" format="rest"/>
            </endpoint>
         </send>
         <drop/>
      </inSequence>
      <outSequence>
         <log level="full"/>
         <send/>
      </outSequence>
   </target>
   <description></description>
</proxy>

Upvotes: 2

Chintana Wilamuna
Chintana Wilamuna

Reputation: 866

Although this comment is not going to suggest you a solution, I can say that this is a bad idea :-) You can try using XSLT instead of PayloadFactory to transform, but again that might choke up the XML parser. Problem is a lot of open source projects/libs that WSO2 products use and you might bump into elsewhere will honour the spec. In the long run, complying to the spec will give you less headaches when you integrate with other external tools/systems. Is it possible to change your rest service so that the service name at least have an underscore in front?

Upvotes: 0

Related Questions