1
votes

I am trying to simply host a REST service as a proxy service in WSO2 ESB. I am using Custom Proxy to do this. When I run the created proxy, I am not able to pass parameters to the proxy service at run time. How do I do this?

My REST service will be hit on a URL of format:http://ip:host/requestMapping/{name}

The parameter 'name' has to be passed from the UI through the ESB to the service through a proxy service hosted on the ESB. Can you help me with the steps to follow to make this work?

I tried using this page: http://wso2.com/library/articles/2013/12/restful-integration-with-wso2-esb/

But that is for creating APIs which I have been successfully in creating. But I am unable to do this using Proxy services.

Basically in my program, when the user interacts with the UI, he enters a name as input. This name has to be passed to the proxy service hosted in the ESB which should forward this as a path variable to my REST service.

Right now, my service body is:

<inSequence>
  <send>
   <endpoint>
   <http method="POST" uri-template="http://ip:port/resourceMapping/{uri.var.name}"></http>

    </endpoint>
   </send>
</inSequence>
<outSequence>
  <send></send>
</outSequence>

When I run this, instead of sending the name as entered by the user, it sends "uri.var.name" to the REST service. On the other hand, if I define a property tag and define a value for it and then do this, the REST service gets the value of the property that I have set. But I need this value to be sent dynamically by the user so I can't define property and value inside.

Please help me.

1
How is your API resource defined ? There should be a {name} somewhere in order to capture its value. For example: <resource methods="GET" uri-template="/some/api/path/{name}"> .. your in/out sequences go here </resource>Philippe Sevestre
I'm not trying to define an API. I'm trying to define a Proxy Service.NiroshaDogra
Well, in this case there are no variables defined so that explains what you see in the resulting URL. Try defining an API as described in the article instead. Please note that this suggestion assumes you´ll use HTTP/REST in order to access your front-end service. If what you want is a SOAP-to-REST proxy, then you should use an HTTP endpoint and set its template variables using <property> mediators. Check the example at docs.wso2.com/display/ESB480/HTTP+EndpointPhilippe Sevestre
Yes u am using HTTP/REST to access the front end service. Firstly, was your suggestion to create an HTTP endpoint for an API or for a proxy service?NiroshaDogra
you can set the property value to a dynamically evaluated property (eg: dblookup) like that: <property action="set" name="uri.var.something" expression="//some/xpath" />Philippe Sevestre

1 Answers

1
votes

I think, the best approach is to use API in this case because the request to the ESB is REST and endpoint also accepting REST. This is the best practice.