0

I have created a Resful WebApplication and upload it in wso2 as a Restful Service

I want to call this RestFul Service using a proxy service in wso,Is it possible

While doing this ,i am not able to get the response

Below is my Proxy Service configuration

<?xml version="1.0" encoding="UTF-8"?><proxy xmlns="http://ws.apache.org/ns/synapse" name="ProxyService" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
    <outSequence>
        <send/>
    </outSequence>
    <endpoint>
        <http method="get" uri-template="http://10.132.97.131:9763/JerseyJSONExample/rest/jsonServices/print/mahi/"/>
    </endpoint>
</target>
<description/>

But while calling this proxy service,i am not able to get the response

If i am simply calling the service

http://10.132.97.131:9763/JerseyJSONExample/rest/jsonServices/print/mahi/

I am getting the response...

Can anyone help me on this what actually is the problem

Community
  • 1
  • 1
Mahesh Narayanan
  • 143
  • 2
  • 19

1 Answers1

0

You can use the following configuration to call a restful service from proxy service

<inSequence>
<property name="HTTP_METHOD" value="GET" scope="axis2" type="STRING"/>
    <send>
        <endpoint>
        <address uri="http://10.132.97.131:9763/JerseyJSONExample/rest/jsonServices/print/mahi/"
                       format="pox"/></endpoint>
    </send>
</inSequence>

More information can be find here

Wenod Pathirana
  • 189
  • 1
  • 6
  • I am not getting the response fully,Actually the rest service will return a json,but while calling using this proxy service,it's not returing the response as json,i am getting onlt the fist value – Mahesh Narayanan Mar 13 '14 at 08:15
  • Add
    before calling the endpoint
    – Wenod Pathirana Mar 13 '14 at 08:23
  • Still I am not getting the output.. I ll explain what i have did Below is my conf `
    `
    – Mahesh Narayanan Mar 13 '14 at 08:40
  • I am using a rest client (mozilla plugin) and put method as GET and i called the proxyservice ,i got the output as like belo `Enter Sandman` Actual ouput need to get is `{"title":"Enter Sandman","singer":"Metallica"}` – Mahesh Narayanan Mar 13 '14 at 08:42
  • But if i put the rest client method as POST , unfortunately i am getting this correct output, How it is happening,it is wrong write `{"title":"Enter Sandman","singer":"Metallica"}` – Mahesh Narayanan Mar 13 '14 at 08:43
  • I deployed a sample restful service in wso2,if am directly calling this service,i am getting the output. Can you please help me on this. I am using wso2carbon(installed esb on this) 4.8.0 – Mahesh Narayanan Mar 13 '14 at 08:44
  • For GET requests you need to make reponse body with parameters wrapped in a root element. Because in Axis2, it maps the JSON message to a SOAP body and it need to have a root element. So can you make the the response something like `{"response" :{"title":"Enter Sandman","singer":"Metallica"}}` – Wenod Pathirana Mar 14 '14 at 08:14
  • Thanks for the reply.. So If the response structure should make it as aroot element,then only we ll get the response properly right? – Mahesh Narayanan Mar 14 '14 at 08:28
  • Can you help me on one more doubt,i need to send the JSOn request to a restful service, pls check this http://stackoverflow.com/q/22397322/2822914 Can you explain me how to do the configuration plss – Mahesh Narayanan Mar 14 '14 at 08:29