WSO2 ESB message id - wso2

Do I have any possibility to find message on WSO2 ESB by MessageId, like urn:uuid:e11893c5-b033-4e99-9473-a43d66b65fbb ? For example if some flow failed and server logged such ID.

Maryan,
ESB itself doesn't log messages anywhere until you tell it to.
a) The first approach is to write incoming and outgoing messages into the log using log mediator:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="YourProxyService" transports="https http" startOnLoad="true">
<target>
<inSequence>
<log level="full">
<property name="MESSAGE_ID" expression="get-property('MessageID')"/>
</log>
...
</inSequence>
<outSequence>
<log level="full">
<property name="MESSAGE_ID" expression="get-property('MessageID')"/>
</log>
...
</outSequence>
</target>
</proxy>
Then you'll be able to find your incoming and outgoing messages in log files as the logs would contains something like following:
INFO {org.apache.synapse.mediators.builtin.LogMediator} - To: http://localhost:9763/services/YourProxyService, From: 127.0.0.1, WSAction: urn:mediate, SOAPAction: urn:mediate, Direction: request, MESSAGE_ID = urn:uuid:e11893c5-b033-4e99-9473-a43d66b65fbb , Envelope: <ENVELOPE_GOES_HERE>
b) Another approach would be to create table in the database and store message id and envelope to it.
Hope this helps.
Vladimir.
UPD: You can also use built in SOAP tracer, but enable it with caution - it hits ESB performance. So I suggest use it only for short term debugging activities.

Yes, you can get the message ID using property mediator,
<property name="MessageID" expression="get-property('MessageID')"/>

As others pointed out, you can use log statements in WSO2 ESB to log the messages and search and find later.
But it becomes complex when the message flow fails at some point, as the message IDs will be different across different message flows.
A simple approach would be to read the incoming messagID and use it till the final response message.
Have a look here for detailed explanation.

Related

WSO2 ESB: Can we use Call Mediator for Rest Service to post (POST HTTP Method) the xml request?

When I create proxy with send mediator with Rest service Post HTTP Method in HTTP endpoint url. Selected the endpoint as HTTP endpoint on proxy and post the request xml without soap envelop, this perfectly works and get the response in the response window.
But when I use the call mediator with the same HTTP end point url configuration, this does not works. I would like to know can we use call mediator for Post HTTP method? When I use Call mediator for the GET HTTP method which require only query parameters and does not require any request xml this works absolutely fine.
Here is the further information:
However issue is resloved by using the address endpoint in callmediator. When I Invoke the proxy from external Restt client ot Soap UI, it does works. If I use the Try this Service option in wso2 ESB will fail with the results 1. When Soap12 endpoint is selected and 2 when HTTP end point is selected as shown below.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="postIDMPCall"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="ContentType" value="text/xml" scope="axis2" type="STRING"/>
<property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
<payloadFactory media-type="xml">
<format>
<organizationList xmlns="">
<xml content>
</organizationList>
</format>
<args/>
</payloadFactory>
<header name="_user" scope="transport" value="username"/>
<header name="_password" scope="transport" value="Password"/>
<call blocking="true">
<endpoint>
<address uri="http://<ip-address>:<port>/<resource-path>/UpdateOrganization"
format="rest"/>
</endpoint>
</call>
</inSequence>
</target>
</proxy>
Output: When soap12 endpoint is selected
Though posted the correct xml service does not recorgonize the correct xml format for soap12 endpoint.
FAILURE
Record is not processed successfully. Please Provide valid Request XML
When Http end point is selected
[2016-04-21 12:07:50,179] INFO - HTTPSender Unable to sendViaPost to url[http://://UpdateOrganization/mediate]
java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
I think we can't use call mediator for this purpose because call mediator is context unaware mediator.
Your call should already perform a post out the box.
Did you try to set format="pox" if you expect simple xml as a response

WSO2 Api Manager log Http request in log mediator

Is there a way to include the http request remote host in the log mediator being used for a specific api?
Having followed the instructions, i can log the soap message, but i have no info regarding the caller of the service.
I currently use the following sequence definition:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="WSO2AM--Ext--In">
<log level="full">
<property name="TRACE" value="Gunet Mediation Extension"/>
</log>
</sequence>
And the result i get when having a call is the following:
INFO - LogMediator To: /SmartSearch/1, WSAction: urn:SearchStudentStatus, SOAPAction: urn:SearchStudentStatus, MessageID: urn:uuid:36f9a5cd-c8cb-4e1e-97a6-f3ebd3303589, Direction: request, TRACE = Gunet Mediation Extension, Envelope: <?xml version='1.0' encoding='utf-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><SearchStudentStatus xmlns="gunet.gr"><SSN>12312312312</SSN><institution>aueb</institution></SearchStudentStatus></S:Body></S:Envelope>
I would like to have information about the remote host that made the specific call. Is that possible, using the log mediator, or should i use a combination of log4j configs?
Thanks!
You can get the remote IP which call the API using following property mediator.
<log level="full">
<property name="Actual Remote Address" expression="get-property('axis2','REMOTE_ADDR')"/>
</log>

WSO2 ESB - How to send response to Intermediate sequence from service provider?

i was going through a video about "Webinar - ESB - An answer to Enterprise Service Integration" by WSO2 ESB . i have a doubt regarding the video .
it is said in the video that , always in sequence will receive the request and out sequence will return the response from the service provider . An ESb can have multiple intermediate sequence and we can, set to which intermediate sequence service provider has to send the response .
How is it possible when we do not have any control over the service provider ? are we using some queue in between ESB and service provider to accomplish ?
Inside a sequence, when you send a request to a service, you can choose the response-handling sequence (service chaining) :
<send receive="personInfoSeq">
<endpoint key="PersonInfoEpr"/>
</send>
When the ESB sends the request, a callback is instanciated (a dedicated thread) which will wait for the reply and then execute the 'receive' sequence configured in the 'send' mediator
Inside a sequence, when you are working with a response message, you can change it to a request message (<property name="RESPONSE" value="false"/>) and send it to another service
Inside a "in" sequence (when you are working with a request message), you can generate a response, sample :
<inSequence>
<header name="To" action="remove"/>
<property name="RESPONSE" value="true"/>
<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
<payloadFactory>
<format>
<ns:getQuoteResponse xmlns:ns="http://services.samples">
<ns:return xmlns:ax21="http://services.samples/xsd">
<ax21:change>4.212070096051944</ax21:change>
<ax21:earnings>-9.567415587431361</ax21:earnings>
<ax21:high>-148.1740146577308</ax21:high>
<ax21:symbol>IBM</ax21:symbol>
</ns:return>
</ns:getQuoteResponse>
</format>
</payloadFactory>
<send/>
</inSequence>

WSO2 ESB and MB Message Store looses Message Body

i m trying to face up to the integration between WSO2 ESB 4.7.0 and WSO2 MB 2.1.0, following the instructions written at this URL:
http://docs.wso2.org/display/MB210/Integrating+WSO2+ESB
In particular i want to use a message store as a queue. So i follow the paragraph: "Integrate Using Message Stores and Processors".
I created the message store and message processor, having previously well configured ESB and MB as showed.
Finally i wrote this proxy:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="MessageStoreQueueProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<send>
<endpoint>
<address uri="http://localhost:8080/RestService/rest/servizio"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
<property name="OUT_ONLY" value="true"/>
<store messageStore="JMSMS"/>
<log level="full"/>
</outSequence>
</target>
<description/>
</proxy>
When my client calls the MessageStoreQueueProxy service, on the Message Broker i can see the "JMSMS message store" counter rightly increased but, when i take a look on the "Content Type" field of each message i see just the "Java MessageObject icon", while, in the "body field", i can read just a "not supported" value.
On the other hand, if i browse the JMSMS "message store" in the ESB i can see that the messages' envelopes look like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<root>
<code>ok</code>
<documentID>2546</documentID>
</root>
</soapenv:Body>
</soapenv:Envelope>
So why the body was lost during the transaction? how can i mantain the body? or how can i recover it from the ObjectMessage in the WSO2 MB?
thanks a lot
"Message Store" does not persist the message as it is in the JMS Queue. it serializes the message and other information into java serialized object and put it into JMS Queue.When "Message Processor" processes the message, it pulls Messages from JMS Queue and deserializes the java serialized object to further process.
Here MB is used as JMS Queue. So Message Store serialize and put in MB queue. So you see serialize java object. If you use message store you won't be able see the content in MB.

Exposing WSO2 ESB as REST for use in JavaScript

I have been digging around in Stackoverflow and WSO2 ESB documentation for days but I have yet to come across any clear answer.
My application is in JavaScript and using the Dojo framework. Ideally all the web services call should be make against REST and returns JSON. I know how to get the SOAP xml to come back as JSON because of this example 440: "http//wso2.org/project/esb/java/4.0.3/docs/samples/advanced_mediation_samples.html#Sample440" I have looked at the sample posted on this blog as well: "http//vvratha.blogspot.ca/2011/11/invoking-restful-service-via-wso2esb.html" I seems to be able to call the proxy service from tools like soapUI and get my result in JSON. So I can only assume that ESB is working properly However when I try to call it using dojo.xhrGet or dojo.io.script.get, the data returns as NULL always!!!
What is the method in REST am I supposed to call for a ESB Proxy Service? If I look at the wsdl of the service, the operation seems to call "mediate" but that did not get me any further. I have looked at example 800: "http//wso2.org/project/esb/java/4.0.3/docs/samples/rest_api_samples.html#Sample800" but I am not clear where to use this.
Note: Please add ":" after http for those http links. I seems to be running out of quotas for hyperlinks.
More information after some help from Ratha:
1. This is how I want to call the proxy service: (There will be more querystring parameters later)
http//loh7:8280/services/TestRestProxy?address=1460%20nicholson%20road
Query string is null from this Mediation Message Tracker dump:
13:10:10,803 [-] [HttpServerWorker-16] INFO Proxy Service TestRestProxy received a new message from : 192.168.7.143
13:10:10,803 [-] [HttpServerWorker-16] INFO Message To: /services/TestRestProxy?address=1460%20nicholson%20road
13:10:10,803 [-] [HttpServerWorker-16] INFO SOAPAction: null
13:10:10,803 [-] [HttpServerWorker-16] INFO WSA-Action: null
13:10:10,803 [-] [HttpServerWorker-16] INFO Using the anonymous in-sequence of the proxy service for mediation
13:10:10,804 [-] [HttpServerWorker-16] INFO Start : Sequence
13:10:10,804 [-] [HttpServerWorker-16] INFO Sequence :: mediate()
13:10:10,804 [-] [HttpServerWorker-16] INFO Start : Log mediator
13:10:10,805 [-] [HttpServerWorker-16] INFO querystring = null
13:10:10,805 [-] [HttpServerWorker-16] INFO End : Log mediator
13:10:10,806 [-] [HttpServerWorker-16] INFO Start : Log mediator
13:10:10,806 [-] [HttpServerWorker-16] INFO End : Log mediator
13:10:10,806 [-] [HttpServerWorker-16] INFO Start : Send mediator
13:10:10,806 [-] [HttpServerWorker-16] INFO Sending message through endpoint : EsriNA10 resolving to address =
This is how the proxy looks like:
Note: I wanted to extract the "address" value and put it in the $1 in the request soap message.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="TestRestProxy" transports="https,http" statistics="disable" trace="enable" startOnLoad="true">
<target>
<inSequence>
<log level="custom">
<property name="querystring" expression="get-property('REST_URL_POSTFIX')" />
</log>
<payloadFactory>
<format>
<GeocodeAddress xmlns="http://www.esri.com/schemas/ArcGIS/10.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Address xmlns="">
<PropertyArray>
<PropertySetProperty>
<Key>Street</Key>
<Value>$1</Value>
</PropertySetProperty>
<PropertySetProperty>
<Key>City</Key>
<Value>Newmarket</Value>
</PropertySetProperty>
<PropertySetProperty>
<Key>State</Key>
<Value>ON</Value>
</PropertySetProperty>
<PropertySetProperty>
<Key>Zip</Key>
<Value>L3Y 9C3</Value>
</PropertySetProperty>
<PropertySetProperty>
<Key>Country</Key>
<Value>CANADA</Value>
</PropertySetProperty>
</PropertyArray>
</Address>
<PropMods xmlns="">
<PropertyArray>
<PropertySetProperty>
<Key>OutputSpatialReference</Key>
<Value xmlns:q2="http://www.esri.com/schemas/ArcGIS/10.0" xsi:type="q2:ProjectedCoordinateSystem">
<WKID>102100</WKID>
</Value>
</PropertySetProperty>
</PropertyArray>
</PropMods>
</GeocodeAddress>
</format>
<args>
<arg expression="$ctx:querystring" />
</args>
</payloadFactory>
<log level="full" category="TRACE" separator="," />
<send>
<endpoint key="EsriNA10" />
</send>
</inSequence>
<outSequence>
<log level="full" separator="," />
<xslt key="out_transform" />
<property name="messageType" value="application/json" scope="axis2" type="STRING" />
<send />
</outSequence>
</target>
</proxy>
In the sample 800 it explains how you can directly invoke RESTAPIs..
For example, if you have your REST service endpoints point that as your service endpoint. Note that the following configuration;
<api name="StockQuoteAPI" context="/stockquote">
<resource uri-template="/view/{symbol}" methods="GET">
Where we define the RESTAPI call stockquoteAPI and defining the context and uritemplate..
So, when you try to execute above API, use curl or other REST client and execute like;
curl -v http://127.0.0.1:8280/stockquote/view/IBM
Here you will see we provide the context and uri template..from that we pick symbol call IBM and sending to stcokquote service..But it is your logic, you can define your own logic in the sequence.
Edit
From browser try like this;
http://localhost:8280/services/yourProxy/<Operation>?param1=21312&param2=wqeqw
Here the "operation" is the operation(which is present at your backend REST service) you try to invoke.
"Mediate" is the default operation..If you want to execute your actual backend service operation provide that operation as i mentioned above.
When you define proxy follow my sample in the blog..
<proxy name="yourProxy" transports="https http" startOnLoad="true" trace="disable">
<target>
<endpoint>
<address uri="Your REST SERVICE ENDPOINT URL"/>
</endpoint>
<inSequenc>
<log level ="custom">
<property name="querystrings" expression=get-property('REST_URL_POSTFIX')/>
</log>
</inSequnece>
<outSequence>
<send/>
</outSequence>
</target>
</proxy>
Try above proxy and see what it logs fro "querystrings"
You can use REST API to invoke allt hese http verbs.Simply define what type of the verb you like to execute..and route the request to the service endpoint
This is a simple introduction part..hope may help you..
http://vvratha.blogspot.com/2012/09/rest-support-in-wso2esb-introduction.html