I need to convert my existing SOAP web service to a REST webservice by using WSO2 ESB. I tried with the given samples in the Documentation successfully. And also I created a transformer proxy and set the end point as my existing WSDL url. In my case I'm getting the response as SOAP. SO how can I change that response into Json in the created proxy? I tried with the outsequences a lot. but coudnt make it success. Can anyone tell me the exact steps to do this.
I riffered [enter link description here][1]
[1]: http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL as web service.
In your REST API (see the example link given in Samisa's answer above) use the following property in out sequence to convert the message type to JSON.
<property name="messageType" scope="axis2" value="application/json"/>
Related
In wso2 esb what is the best practice for Endpoint maintenance. From some article I got to know that we can read from file So, if this the best approach how achieve this one.
In a scenario where the endpoint is saved as a file within the carbon registry (You can even upload the file via management console or can use WSO2 EI Tooling to create an endpoint template), we can read the content of the endpoint as follows.
Add the endpoint registry resource.
Log the endpoint content using the following synapse configuration. (Can even retrieve specific attributes within the endpoint using their xpath expressions)
<log level="custom">
<property name="Endpoint Content:" expression="$ctx:endpointFile//*"/>
<property name="Endpoint URL:" expression="$ctx:endpointFile//*[local-name() = 'address'][1]/#uri"/>
</log>
You can see the logged endpoint content as below.
There are 3 ways to Endpoint Maintenance.
Using ESB Tooling
From Command Line
Using a Script
More details can be found in WSO2 Documentation.
I am using Wso2 DSS and building RESTful webservices from an oracle DB and trying to return custom error messages in case no records found or invoked using invalid parameters.
And I also want to control the HTTP return code for these error responses.
For example. Lets say there is a webservice: /getemployee/{empno} that returns employee details in JSON/XML format.
If I call getemployee with an empno that doesn't exists in the DB then
I want the response to be like something similar to below
<Error>
<Error_code>No employee found </Error_code>
</Error>
It should not have the normal employee details message structure that would go as response when an employee is found.
At the moment if record is not found by the underlying query DSS just returns empty message with just root element.
The HTTP return code for this response should be 404 as opposed to the success code 200.
By default all responses get HTTP return code 200 in DSS.
Is this possible at all just by using DSS?
Appreciate your help
You would need WSO2 ESB to do that. You can make a proxy service in ESB that will call DSS and then transform the response for you based on its contents and your needs. You can do so using XSLT.
You can set manually the desired HTTP return code, using the property HTTP_SC:
<property name="HTTP_SC" scope="axis2" type="STRING" value="404"/>
You can also use switch and payload factory, if you know what you will receive and the output will be a static one.
Good Day!
I have a WSO2 ESB proxy service which is calling WSO2 DSS Service. It is inserting the data to mysql table. it is working as expected. but if there is any issue in the DSS Service, I am getting faults with different soap response formats. like
if the service is inactive or stopped, then getting response like
<soapenv:Body><soapenv:Reason xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">.......
if the service is facing issue while inserting the data, then getting response like
<soapenv:Body><axis2ns134:DataServiceFault xmlns:axis2ns134="http://ws.wso2.org/dataservice"><axis2ns134:current_params......
and some other cases getting different responses.
but is ESB, those errors are not capturing and not firing "faultsequence" even I explicitly set the below property
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true" scope="default" type="STRING"/>
Can you please guide me how to handle/catch those errors in ESB Proxy?
Thanks,
Vinoth
see if this documentation helps you.
https://docs.wso2.com/display/ESB490/Fault+Mediator
https://docs.wso2.com/display/ESB490/Error+Handling
Att;
Vitor Darela
I'm trying to setup a proxy for my RESTful API using WSO2 API Manager. My problem is that the responses from the backend API are left untouched so all the urls that connect to other endpoints still reference the backend server rather than the proxy. I need a way to replace those url values in the response body to point to the proxied api. I understand this can be accomplished via Mediation Extensions, using ESB Mediators.
I'm not familiar enough with them to pick the one better suited for the job. URLRewrite mediator looks pretty straightforward, but it doesn't seem to apply to the message body but the headers. Payload Factory seems to require a fixed structure for the message, which is not very convenient for me, since I need it to work on the different responses that my API provides (and I wouldn't want to maintain those structures in the mediator definition).
I've managed to solve it by setting the headers my application checks to build its urls:X-Forwarded-Host and X-Forwarded-Proto.
So I've created a Header Mediator that looks like:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="WSO2AM--Ext--In">
<header name="X-Forwarded-Host" expression="get-property('transport','Host')" scope="transport"/>
<header name="X-Forwarded-Proto" value="https" scope="transport"/>
</sequence>
And that did the trick.
Quick question. When using the Web Harvesting feature of WSO2 DSS, how do I send parameters via POST to a service such as the one configured below:
<config>
<var-def name="someName">
<html-to-xml>
<http url="http://server.yoyodyne.com/service/entryPoint?doQuery=someValue&someKey=anotherValue" method="post"/>
</html-to-xml>
</var-def>
</config>
For example, if I wanted to send via POST the vars "firstField", "secondField", and "someFileName", where would I define those in the config? The documentation does not seem to cover this.
At the moment DSS only support simple HTTP Get and extract web data from given URL for Web scraping.
Regards,
Amani