WSO2 ESB Proxy Basic Service Chaining - wso2

this is what I thought would be a fairly straight-forward service chaining scenario.
All I want to do it forward some data to a proxy service, that proxy service will then iterate over the data and use an ID ("entity_id") from that data (which it can successfully retrieve) to look up a resource sitting in WSO2 Data Services Server. Once it has the result of that request, I want to forward it to another application (RequestBin, in this case).
Please take a look at my proxy configuration below:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="pollService"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
<iterate id="iter1"
expression="//*[local-name()='Change']"
sequential="true">
<target sequence="anon">
<sequence>
<log level="full"/>
<property name="uri.var.entityid" expression="//*[local-name()='entity_id']"/>
<call>
<endpoint>
<http method="get"
uri-template="http://54.66.155.36:9764/services/civicrm/activity/{uri.var.entityid}"/>
</endpoint>
</call>
<log level="full"/>
<call>
<endpoint>
<http method="post" uri-template="http://requestb.in/1c79v711"/>
</endpoint>
</call>
<log level="full"/>
</sequence>
</target>
</iterate>
</inSequence>
</target>
<description/>
</proxy>
I currently do not get any indication that those two calls have fired at all.
Any assistance would be greatly appreciated.
Thank you.

you can enable the wirelog and verify whether calls have fired or not.
please refer the following blog post to learn about wirelog.
1 http://mytecheye.blogspot.in/2013/09/wso2-esb-all-about-wire-logs.html

Could you also give a sample message (what is going into the proxy) , and to see a finer-grain detail of what is going on in your proxy , go into [esb-home]/repository/conf/ and open the log4j.properties file , and set
log4j.category.org.apache.synapse=DEBUG , also do as #robin suggested. Try putting
<log level="full" category="DEBUG" separator="-----:-----"/>
in your proxy where you want to see the state of the message at that point.

Related

WSO2 ESB reliable messaging

I have tried this sample "https://docs.wso2.com/display/ESB470/Sample+102%3A+Reliable+Message+Exchange+with+Back-End+Server+Using+WS-ReliableMessaging+1.1", and unfortunaly I couldn't understand the config explained in this sample. the config is:
<definitions xmlns="http://ws.apache.org/ns/synapse">
<in>
<RMSequence single="true" version="1.1"/>
<send>
<endpoint name="reliable">
<address uri="http://localhost:9000/services/ReliableStockQuoteService">
<enableRM/>
<enableAddressing/>
</address>
</endpoint>
</send>
</in>
<out>
<header name="wsrm:SequenceAcknowledgement" action="remove"
xmlns:wsrm="http://docs.oasis-open.org/ws-rx/wsrm/200702"/>
<header name="wsrm:Sequence" action="remove"
xmlns:wsrm="http://docs.oasis-open.org/ws-rx/wsrm/200702"/>
<header name="wsrm:AckRequested" action="remove"
xmlns:wsrm="http://docs.oasis-open.org/ws-rx/wsrm/200702"/>
<send/>
</out>
There is no place that explain where to use this config. What is the definitions tag? What are in and out tags?
I have tried this proxy service to invoke a reliabl-messaging enabled backend.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="reliableClient"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<RMSequence single="true" version="1.0"/>
<send>
<endpoint>
<wsdl service="reliableBackEnd"
port="reliableBackEndHttpSoap11Endpoint"
uri="http://localhost:9763/services/reliableBackEnd?wsdl">
<enableAddressing/>
<enableRM/>
</wsdl>
</endpoint>
</send>
</inSequence>
<outSequence>
<header xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm"
name="wsrm:SequenceAcknowledgement"
action="remove"/>
<header xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm"
name="wsrm:Sequence"
action="remove"/>
<header xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm"
name="wsrm:AckRequested"
action="remove"/>
<send/>
</outSequence>
</target>
<description/>
</proxy>
but it is getting time out. the backed is hosting in the same ESB 4.8.1, with default RM-Policy enabled.
#Reza,
definitions tag is the root tag of the ESB synapse config. Under the definitions tag, all the synapse artifact related configs such as proxy services, sequences, and etc are included.
Also regarding the sample you are referring,you are referring to an older version of 4.7.0 and make sure you have enabled nhttp transport. Instead of using the older version, I would like to suggest you use a newer version. Please refer [1], a nice article written by Buddhima.
[a] https://buddhimawijeweera.wordpress.com/2015/09/05/reliable-messaging-with-wso2-esb/

How to call RestFullService using Proxyservice in wso2

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
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

Why WSO2 Send Mediator doesn't wait for response?

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 to call webservice in WSO2 proxy

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.

ESB doesn't return anything from the GET service failing with NPE

I've configured a proxy service to run some XSBRL validation stuff that accepts a get request amd return XML validation results. Here's proxy service configuration:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="XBRLValidationRESTService" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
<property name="REST_URL_POSTFIX" value="/example.xbrl/validation/xbrl?media=xml" scope="axis2"/>
<property name="HTTP_METHOD" value="GET" scope="axis2"/>
<send>
<endpoint>
<address uri="http://localhost:10000/rest/xbrl" format="pox"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="full"/>
<send/>
</outSequence>
</target>
<description></description>
</proxy>
In the log file I can see that the underlying service responds with expected response, however the client receives nothing back because ESB fails with NPE for some reason.
Request used from localhost:
curl -k https://localhost:9443/services/XBRLValidationRESTService
Full log: http://pastebin.com/A5jB9wMF
What is the potential reason for that and how that could be fixed.
Thanks,
Vladimir.
Do you run ESB with blocking transport? By default esb uses NIO transport and the port is 8280. your proxy service url, will be;
http://localhost:8280/services/XBRLValidationRESTService
Rather putting log full state, use descriptive logs to identify message paths,