I am developing an API in WSO2 EI 6.6 with an API context that has several parts (/context1/context2/...) I found out that it only works if I have a simple context like /context1. Otherwise when I call the API the behavior is like there was no match with the url of the API.
This work properly in ESB 4.9 and I have found this problem when building it in EI 6.6.
Here there is a sample that not work using this url http://host:port/context1/context2/template
<api xmlns="http://ws.apache.org/ns/synapse" name="API1" context="/context1/context2">
<resource methods="GET" uri-template="/template*">
<inSequence>
<send/>
</inSequence>
<outSequence>
<send/>
</outSequence>
</resource>
</api>
And a sample that works properly using the URL http://host:port/context1/template
<api xmlns="http://ws.apache.org/ns/synapse" name="API1" context="/context1">
<resource methods="GET" uri-template="/template*">
<inSequence>
<send/>
</inSequence>
<outSequence>
<send/>
</outSequence>
</resource>
</api>
Any help? Am I calling the API properly? Is it a bug?
I tried the below API and it worked(http://localhost:8280/context1/context2/template2).
<api xmlns="http://ws.apache.org/ns/synapse" name="API1" context="/context1/context2">
<resource methods="GET" uri-template="/template*">
<inSequence>
<loopback/>
</inSequence>
<outSequence>
<payloadFactory media-type="json">
<format>{"Hello" : "World"}</format>
<args/>
</payloadFactory>
<send/>
</outSequence>
</resource>
</api>
Maybe the behaviour of the Send mediator has changed. Can you elaborate more on what you are trying to do?
I found the problem. I was trying to use in the context the word "odata" and it seems to be a reserved word in EI. It makes sense since dss is now inside EI, and dss can generate open data dataservices, and probably, odata it is part of the context to call these detaservices.
Related
I've just started looking at WSO2 enterprise integrator.
I'm currently stuck when I'm trying to create an API which calls a backend service which requires authentication.
I'm currently stuck trying to add a simple header which its suppose to send to the backend as it needs authentication to access it.
I'm using their eclipse tooling and my XML currently looks like this.
<?xml version="1.0" encoding="UTF-8"?>
<api context="/one" name="singleRestApi" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET">
<inSequence>
<header name="Authorization" scope="transport" value="Basic ZWNYGWRtaH42Q2xvdGRBZG1pbjmeMw=="/>
<send>
<endpoint key="repos"/>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</resource>
</api>
Currently following the integration tutorials: here
Any help or direction would be greatly appreciated.
You should try to put your Authorization in a property instead of an header (if you want to do a simple basic authentication)
<?xml version="1.0" encoding="UTF-8"?>
<api context="/one" name="singleRestApi" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET">
<inSequence>
<property action="remove" name="REST_URL_POSTFIX" scope="axis2"/>
<property name="Authorization" scope="transport" value="Basic ZWNYGWRtaH42Q2xvdGRBZG1pbjmeMw=="/>
<send>
<endpoint key="repos"/>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</resource>
</api>
the <property action="remove" name="REST_URL_POSTFIX" scope="axis2"/>
part is to remove the api context (after /one) when sending to your backend endpoint, if you need to keep it you can remove this line
I have a rest end point in WSO2ESB (4.8),I need to read query parameter to set as dynamic payload as the my business ,But i failed to read it due to newer with wso2 ESB.Any help ?
The bellow code may help you
<api xmlns="http://ws.apache.org/ns/synapse" name="sample" context="/api/sample">
<resource methods="OPTIONS GET" uri-template="/{val1}/groups/{val2}.json?q1={v1}&q2={v2}">
<inSequence>
<property name="uri.var.q1" expression="$url:q1"></property>
<property name="uri.var.q2" expression="$url:q2"></property>
<property name="uri.var.val1" expression="get-property('uri.var.val1')"></property>
<property name="uri.var.val2" expression="get-property('uri.var.val2')"></property>
<send>
<endpoint>
<http method="GET" uri-template=""></http>
</endpoint>
</send>
</inSequence>
<outSequence>
<send></send>
</outSequence>
</resource>
</api>
Define a REST API inside ESB and access to query params with get-property('query.param.xxx') or get-property('uri.var.yyy'), sample :
<resource methods="GET" uri-template="/testwso2/{symbol}?arg1={value1}">
get-property('query.param.arg1')
get-property('uri.var.symbol')
I am trying to use WSO2 ESB (version 4.8.1) to invoke externally hosted SOAP web services. To try it out I was using a public web service for weather information (http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL), more specifically the GetWeatherInformation operation.
I have successfully consumed the web service using the soapUI tool.
I am a newcomer to SOAP and ESB, so I tried to follow a number of blog entries, but I keep on getting errors. I tried using proxy service, payload factory and send but still didn't manage. Can somebody please help me with setting this up?
Thanks
Here come a sample API to invoke GetWeatherInformation :
<?xml version="1.0" encoding="UTF-8"?>
<api xmlns="http://ws.apache.org/ns/synapse"
name="testws3api"
context="/testws3api">
<resource methods="GET" url-mapping="/GetWeatherInformation">
<inSequence>
<payloadFactory media-type="xml">
<format>
<GetWeatherInformation xmlns="http://ws.cdyne.com/WeatherWS/"/>
</format>
<args/>
</payloadFactory>
<send>
<endpoint>
<address uri="http://wsf.cdyne.com/WeatherWS/Weather.asmx" format="soap11"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</resource>
</api>
You just have to send a GET http request to http://esb.hostname:8280/testws3api/GetWeatherInformation (use SoapUI or type this address in your internet browser) and you will get back the XML response from the Weather WS
It works with this proxy conf deployed in WSO2 ESB v4.8.1 :
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="testws3"
transports="https http"
startOnLoad="true"
trace="disable">
<target>
<endpoint>
<wsdl service="Weather"
port="WeatherSoap12"
uri="http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL"/>
</endpoint>
<outSequence>
<send/>
</outSequence>
</target>
<publishWSDL uri="http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL"/>
</proxy>
I have a WSO2 ESB-4.6.0 proxy that calls another proxy that calls an webservice.
Proxy1 --> Proxy2 --> Endpoint
If I directly call the second proxy via soapUI, the response is correctly returned and printed, but if I call the first proxy, then an blank body is returned.
In the ESB log, the outSequence of the Proxy1 is printed before the outSequence of the Proxy2.
Seems like the Send mediator present in the inSequence of the Proxy1 is making an asynchronous call to the Proxy2.
I've tried to replace the Send mediator by the Callout mediator, but the result is the same.
Follow this tutorial, but it didn't works also.
How to forward the response for the Proxy2 to the caller?
Please help. It's killing me!
EDIT
Problem solved! I was using a wrong port to specify the serviceURL parameter for Callout mediator.
EDIT
The current proxies configuration:
Proxy1 (calling Proxy 2 - ManageWorkforce):
<proxy xmlns="http://ws.apache.org/ns/synapse" name="GetAppointmentSchedulePortalReqCS" transports="http https" startOnLoad="true" trace="disable">
<target>
<inSequence>
<xslt key="conf:ManageWorkforce/xslt/GetAppointmentSchedulePortalReqCS_Request.xsl"/>
<header name="Action" value="getAppointment"/>
<send>
<endpoint>
<address uri="https://localhost:9443/services/ManageWorkforce"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<xslt key="conf:ManageWorkforce/xslt/GetAppointmentSchedulePortalReqCS_Response.xsl"/>
<send/>
</outSequence>
<faultSequence/>
</target>
<publishWSDL key="conf:ManageWorkforce/GetAppointmentSchedulePortalReqCS.wsdl" />
</proxy>
Proxy 2 (calling Proxy3 -GetAppointmentPeopleProvCS):
<proxy xmlns="http://ws.apache.org/ns/synapse" name="ManageWorkforce" transports="https http" startOnLoad="true" trace="disable">
<target>
<inSequence>
<switch source="get-property('Action')">
<case regex="getAppointment">
<callout serviceURL="https://localhost:8243/services/GetAppointmentPeopleProvCS" action="getAppointment">
<source xmlns:s12="http://www.w3.org/2003/05/soap-envelope" xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/" xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
<target xmlns:s12="http://www.w3.org/2003/05/soap-envelope" xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/" xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
</callout>
</case>
<!-- another cases -->
<default/>
</switch>
<property name="RESPONSE" value="true" scope="default" type="STRING"/>
<header name="To" action="remove"/>
<send/>
</inSequence>
<outSequence>
<drop/>
</outSequence>
<faultSequence/>
</target>
<publishWSDL key="conf:ManageWorkforce/ManageWorkforce.wsdl"/>
</publishWSDL>
</proxy>
Proxy 3 (calling the service -GetAppointment):
<proxy xmlns="http://ws.apache.org/ns/synapse" name="GetAppointmentPeopleProvCS" transports="http https" serviceGroup="" startOnLoad="true" trace="disable">
<target>
<endpoint key="GetAppointment"/>
<inSequence>
<xslt key="conf:ManageWorkforce/xslt/GetAppointmentPeopleProvCS_Request.xsl"/>
</inSequence>
<outSequence>
<xslt key="conf:ManageWorkforce/xslt/GetAppointmentPeopleProvCS_Response.xsl"/>
<send/>
</outSequence>
<faultSequence/>
</target>
</proxy>
Final endpoint (service):
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="GetAppointment">
<address uri="http://10.13.6.75:9764/services/GetAppointment" />
</endpoint>
There are two mediators to invoke web services. Those are Callout Mediator and Call Mediator. The Callout mediator performs a blocking call and the Call Mediator performs a non-blocking call.
So, you should use Call mediator if you consider about performance. It's availble in ESB 4.8.0.
There are two samples for these in wiki docs.
There is another sample for Call Mediator from Dushan's blog. This has more complex mediators, but you can try out.
This is just a quick answer.
I hope this helps.
Thanks!
Proxy1 waits for the response from Proxy2 even you use the send mediator.
outSequence of the Proxy1 should not get executed before the execution of outSequence of Proxy2.
Switch to Callout Mediator is not the ideal solution for this.
I think there should be something wrong with the proxy configuration.
If you can post the proxy configuration here, we might be able to give you a help to solve this.
how I can call web service inside of proxy? Proxy itself works fine, and I added call of logging web service in "in" sequence. I create call using payload factory + send.
Problem is, that proxy now returns result of this logging web service instead of
what web service should return. There is address end point defined in "out" sequence.
I am using WSO2 ESB 4.6.0.
This is the simple example of calling web service inside of the proxy. You need to up back-end service before create the proxy
<proxy xmlns="http://ws.apache.org/ns/synapse" name="customPro" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<send>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
</inSequence>
<out-sequence>
<send/>
</outSequence>
</target>
<publishWSDL uri="http://localhost:9000/services/SimpleStockQuoteService?wsdl"/>
<description></description>
</proxy>
You need to define web service url within the end-point in tag
As well as, this kind of send mediator return end-point response to outSequence
by default.
You can get good understanding of these if you go through the ESB documentation from following url
http://docs.wso2.org/display/ESB460/Samples
If you need further help, feel free to ask here
There are two ways you can achieve the logs
1. Log ESB incoming and outgoing messages through wire log.
To enable debug mode for wire logs;
- ESB console > Configure > Logging
- Set “org.apache.synapse.transport.http.wire” level to “DEBUG”.
In the log, it indicates >> incoming messages to ESB
<< outgoing messages from ESB
2. Use Logs at the appropriate place
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="TestProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full">
<property name="test" value="incomming to ESB-----------------------"/>
</log>
<send>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
<log level="full">
<property name="test" value="outcomming from ESB-----------------------"/>
</log>
</inSequence>
<outSequence>
<log level="full">
<property name="test" value="incomming to ESB-----------------------"/>
</log>
<send/>
<log level="full">
<property name="test" value="outcomming from ESB-----------------------"/>
</log>
</outSequence>
</target>
<publishWSDL uri="http://localhost:9000/services/SimpleStockQuoteService?wsdl"/>
<description/>
</proxy>
If it is resolve your problem, please flag as answered.