2
votes

My Proxy Service deployed on ESB is calling another standalone REST service. This service returns HTTP status 200 along with some data in the response body. My question is how I can retrieve HTTP status from response. Here is my configuration:

   <proxy name="CQProxy"
          transports="https http"
          startOnLoad="true"
          trace="disable">
      <description/>
      <target>
         <inSequence>
            <switch source="get-property('Action')">
               <case regex="getTaskTicket">
                  <sequence key="GetTaskTicket"/>
               </case>
               <default/>
            </switch>
         </inSequence>
         <outSequence>
            <log>
               <property xmlns:ns="http://org.apache.synapse/xsd"
                         name="Status"
                         expression="get-property('HTTP_SC')"/>
            </log>
            <send/>
         </outSequence>
         <faultSequence/>
      </target>
      <publishWSDL key="gov:/services/cqproxy/CQProxy.wsdl">
         <resource location="CQProxy.xsd" key="gov:/services/cqproxy/CQProxy.xsd"/>
      </publishWSDL>
   </proxy>
   <sequence name="GetTaskTicket">
...
      <property name="REST_URL_POSTFIX"
                value="/16783484?oslc.select=dcterms:title,oslc_cm:status"
                scope="axis2"
                type="STRING"/>
      <property name="HTTP_METHOD" value="GET" scope="axis2" type="STRING"/>
      <send>
         <endpoint>
            <address uri="http://.../simpleQuery"
                     format="rest"/>
            <property name="OSLC-Core-Version" value="2.0" scope="transport"/>
            <property name="Accept" value="application/rdf+xml" scope="transport"/>
         </endpoint>
      </send>
   </sequence>
...

I tried the following code:

<log>
<property xmlns:ns="http://org.apache.synapse/xsd" name="Status" expression="get-property('HTTP_SC')"/>
</log>

And this one too:

<log>
<property xmlns:ns="http://org.apache.synapse/xsd" name="Status" expression="get-property('axis2', 'HTTP_SC')"/>
</log>

But all of them returned null.

1

1 Answers

5
votes

After reading WSO2 documentation in more details, I found the right answer:

<property xmlns:ns="http://org.apache.synapse/xsd" name="Status" expression="$axis2:HTTP_SC"/>

It is weird that the documented get-property('axis2', 'HTTP_SC') does not work.