Call WSO2 DSS service using ajax? - wso2

I have one data service in WSO2 DSS. And also its possible to call using browsers.But i can't make a request using ajax to call this service.I think CORS issue is occurring.So i want to add Access-Control-Allow-Origin parameter to response header.How this is possible in WSO2 DSS ,Any suggestion ?

I think you can put a custom headers by adding axis2 custom out flow handler.
http://shivendra-tripathi.blogspot.com/2010/04/adding-handler-in-axis2.html?m=1
http://shivendra-tripathi.blogspot.com/2010/04/adding-soap-header-in-axiom.html?m=1

Related

Parameters in POST call to Data Service in Enterprise Integrator

I'm migrating some data services from DSS to EI but I have problems with the parameters in POST calls. I published a Data Service with a query exposed as a REST resource using the methods POST and GET, just for testing. Then I try to call it using cURL.
The GET is easy because I only need to append the parameter to the URL, but for the POST I try passing it using -d and a JSON or XML structure but always the server responds with error 400 (bad request).
If the resource have no parameters both calls works fine.
Can anyone tell me the right way to pass the parameters to the RESTFUL resource when I use the POST method?
If you publish this service as wsdl service do you have same problems with methods, thats analogies to your post methods? I was catch similar problem when don't set request_box parameter of my service to on. It was look as I send request without parameters, but they was send correcltly in fact.

Error message in wso2 dss

I'm using wso2 esb4.7.0 and wso2 dss 3.1.0.I have created a dataservice in dss and tested using try this service tool.It's working fine but when same dataservice is being fetch in esb using it's adress endpoint it showing following error -
ERROR {org.wso2.carbon.statistics.internal.ResponseTimeCalculator} - wso2statistics.request.received.time is null in the IN MessageContext
why so?is their any problem with esb?or it's internal problem?please let me know..
You have to set message headers using Header mediator. At least you have to set "To" and "Action" headers before you send payload to the data service. To get the write value of To and Action headers you can use Soap Tracer tool in monitor tab of WSO2-DSS management console. Run the tool, try the data service and refresh the tool to see the results of your trying. In the left side of the page of Soap Tracer tool you will see the To and Action, copy values from there and put them in header mediators you are using.

URI templates in WSO2 API Publisher

Is it possible to register endpoints with URI templates in the API Publisher that ships with WSO2 API Manager version 1.4.0? For example, I would like to register an endpoint such as:
/jobs/{jobid}/pems
After saving an API, I can see this bit in the API config file:
<resource methods="GET" url-mapping="/jobs/{jobid}/pems">
I have tried manually changing the XML file from url-mapping to uri-template, i.e., to:
<resource methods="GET" uri-template="/jobs/{jobid}/pems">
but I still get "No matching resource found in the API for the given request". In any case, this is not a good work around since we need developers to be able to register these endpoints from the publisher application. Whenever changes are saved to an API from within the API Publisher interface, 'uri-template' gets reverted back to 'url-mapping'.
Thanks in advance.
This is due to APIPublisher app only supports URL-Mappings when defining API resources.
If you want to define a uri-template ,instead of a url-mapping,you can achieve this from changing the api xml manually.
But before that make sure,when creating the API,you have define the API with a valid url-mapping.So in your trying API,first please edit the API from APIPublisher as keeping a valid url-mapping pattern for API resources and then change its xml to match with your mentioned uri-template pattern.
Thanks;
we don't currently support uri-template patterns. We support only url-mappings.
Even , if you edit the backend API configuration (that is, api configuration file ) to url-mappings, it wont work, because we validate request before the request get hits the mediation engine.
You can use ESB RESTApi as your backend service endpoint.That is, define the RESTAPI in wso2esb, with uri-templates(it is supported out of the in ESB) and point that API as the service endpoint from wso2APIManager with url-mappings pattern.
I would like to add some more points.As I mentioned earlier,WSO2 APIManager supports uri-templates.Only api-publisher app UI is not allowing to add uri-templates.
When creating the API from the Publisher UI, you have to give the resource mapping as /* or valid url-mapping. Then when the synapse api is created, you have to change that xml file to uri-template and then change the /* to the uri-template pattern.
Hope above will help you to resolve your issue.
Thanks;

WSO2 ESB : Invoking selective operation of an endpoint?

I have created a WSO2-DS SOAP service with three operations, want to invoke a selective operation of that endpoint from a REST API ESB service.
Looks like the endpoint does not provide option to filter further based on operation.
Any help appreciated..
Thanks,
Wajid
Header mediator should work ... header name="Action" value="soap action"

Proxy for an HTTP request WSO2 ESB

I wonder if it is possible to send an HTTP request throuht WSO2 ESB. I have an integration with a system that consist only in invoking an URL... it would be like a kind of redirection.
Can I do that in WSO2 ESB?
Regards
I have found this link about restfull services in WSO2 ESB:
http://wso2.org/library/articles/2012/10/implementing-restful-services-wso2-esb
I think this is a better way to handle http requests & responses in wso2 esb, rather than the way they are treated in the links you provide. What do you think about that?
Below links will be help you to find a solution to your question.
http://wso2.org/library/knowledge-base/2011/03/handling-httpget-request-invoking-external-web-service-wso2-esb
http://docs.wso2.org/wiki/display/ESB451/Handling+HTTP-get+Requests+from+WSO2+ESB+and+Calling+an+External+Web+Service