2

I am new to wso2.. I have asked lot of question regarding wso2 proxy service,i am not getting a correct response,can anyone help me on this please

I want to send a JSON request to a Restful webservice using a WSO2 proxy service.. I have tried the below configuration

<target>
    <inSequence>
        <log level="custom">
            <property name="in seq --------------of proxy" expression="$trp:Content-Type"/>
        </log>
        <property name="messageType" value="application/json" scope="axis2" type="STRING"/>
        <log level="custom">
            <property name="in seq --------------of proxy" expression="$trp:Content-Type"/>
        </log>
        <property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
        <send>
            <endpoint>
                <address uri="http://10.132.97.131:9763/RESTfulExample/rest/json/metallica/post/"/>
            </endpoint>
        </send>
    </inSequence>
    <outSequence>
        <send/>
    </outSequence>
    <faultSequence>
        <log level="full">
            <property name="MESSAGE" value="Executing default &quot;fault&quot; sequence"/>
            <property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
            <property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
        </log>
    </faultSequence>
</target>

I am not getting the response :( The response is also a JSOn

JSON REQUEST ---- JSON RESPONSE

Need to do this using a proxy service

i am getting the error as below

To: /services/FilterMediatorProxy.FilterMediatorProxyHttpEndpoint/, From: 10.132.97.131, Direction: request, MESSAGE = Executing default "fault" sequence, ERROR_CODE = 0, ERROR_MESSAGE = Unexpected error during sending message out, Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><Body></Body></soapenv:Envelope>

I am passing the JSON request as

{"title":"Enter Sandman","singer":"Metallica"}

But see the below error,it is not passing properly

Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><Body></Body></soapenv:Envelope>

It is trying to send as SOAP (xml format)

What configuration i have to do for this ? I am using wso2 carbon 4.2.0 and installed ESB on this

Please help me for the correct proxy service confiration

Thanks a lot in advance

Community
  • 1
  • 1
Mahesh Narayanan
  • 143
  • 2
  • 19
  • What is the json builder you are using? Can you change the message formatter to `` and the message builder to `` – Wenod Pathirana Mar 14 '14 at 09:06
  • @Wenod I have checked the axis2.xml ` ` is there – Mahesh Narayanan Mar 14 '14 at 09:34
  • @Wenod I changed,now i am getting the following error `To: /services/EventMastroProxyService.EventMastroProxyServiceHttpEndpoint?method=POST, From: 10.132.97.131, Direction: request, MESSAGE = Executing default "fault" sequence, ERROR_CODE = 0, ERROR_MESSAGE = Unexpected error during sending message out, Envelope: Enter SandmanMetallica` – Mahesh Narayanan Mar 14 '14 at 09:40
  • @Wenod Below is my RestFul Service POST Method `@POST @Path("/post") @Consumes(MediaType.APPLICATION_JSON) public Response createTrackInJSON(Track track) { System.out.println("Tack Object " +track); Gson gson = new Gson(); String json = gson.toJson(track); return Response.status(201).entity(json).build(); }` I am passing the Json Request as `{"title":"Enter Sandman","singer":"Metallica"}' **title** and **singer** are the two variables of the POJO Class **Track** – Mahesh Narayanan Mar 14 '14 at 09:41
  • @Wenod Got the response Properly..Thanks alot ,, I have set the **** before sending,so it's properly formatted the JSON and got the RESPONSE (JSON) as well.. :) – Mahesh Narayanan Mar 14 '14 at 12:56
  • @Wenod Can you help me on this pls http://stackoverflow.com/q/22405391/2822914 – Mahesh Narayanan Mar 14 '14 at 12:58
  • Hi Mahesh Narayanan, I got the answer to my problem because your this post. Thank you. When you find answer please add it the answer area. It will help others. – Priyantha Jul 03 '17 at 06:15

0 Answers0