1
votes

I have been given a REST URI from my client which is as follows:

https://vm3.digitary.net/verifier/HEDDRequestDocumentAccess

Following request xml has to be POSTed to the above URI to get the response xml.

<documentAccessRequest   xmlns="http://www.digitary.net/schema/dare/hedd/documentAccessRequest/2013" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.digitary.net/schema/dare/hedd/documentAccessRequest/2013 http://www.digitary.net/schema/dare/hedd/documentAccessRequest/2013">
                    <head>
                    <institutionCode>BBCU</institutionCode>
                    <username>HEDDUser</username>
                    <password>HEDDPass</password>
                    </head>
                    <body>
                       <heddEnquiryId>12347895844</heddEnquiryId>
                       <enquiree>
                          <email>[email protected]</email>
                          <firstName>Jane</firstName>
                          <lastName>Doe</lastName>
                       </enquiree>
                       <enquirer>
                          <organisation>BBC</organisation>
                          <contactName>Jeremy Clarkson</contactName>
                       </enquirer>
                       <documentRequested>HEAR</documentRequested>
                    </body>
                </documentAccessRequest>

Now I have the requirement to make my own wrapper REST API in WSO2 ESB 4.6.0 which would simply call the above mentioned REST URI having the same request and response XML. The idea is to make the pass through REST API to above mentioned API.

I have implemented the following REST API:

    <api xmlns="http://ws.apache.org/ns/synapse" name="TestDareRest" context="/documentRequest" hostname="46.137.187.137" port="8280">
   <resource methods="POST" url-mapping="/request/*">
      <inSequence>
         <log/>
         <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
         <send>
            <endpoint>
               <address uri="https://vm3.digitary.net/verifier/HEDDRequestDocumentAccess" format="pox"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <log/>
         <property name="ContentType" value="application/xhtml+xml" scope="axis2"/>
         <send/>
      </outSequence>
   </resource>
</api>

But above API is not working at all and it is gving loads of errors in the esb console. I am using the SOAPUI to test this REST service and posting the same request xml from there. The service is deployed on our public Ip server and can be seen by login in to following

https://46.137.187.137:9443/carbon/admin/index.jsp with username/pwd as admin/admin

I have tried setting both media type in SOAPUI as text/xml and application/xml

In case of text/xml it is giving error as follows:

org.apache.axiom.soap.SOAPProcessingException: First Element must contain the local name, Envelope , but found documentAccessResponse at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.constructNode(StAXSOAPModelBuilder.java:305)

In case of application/xml it is giving following error

INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:53a782ab-2081-4cb1-9e94-910b75816361, Direction: response [2013-04-10 16:05:12,911] ERROR - PassThroughHttpSender Failed to submit the response java.lang.UnsupportedOperationException

Please help me with this issue as it has got much critical to me.

Thanks in Advance Shakshi

1

1 Answers

0
votes

Can you switch the transport to nonblocking transport and check? You can change the transport sender and receiver in the axis2.xml. The media type is to be application/xml ..not the text/xml, which is used fro soap requests.

To post a request you can use curl utility.

# curl -X POST -d @request.xml "URL"