I am bit confused with WSO2 ESB aggregator mediator.
I need to send three messages to different systems via WebServices, but the three systems have different message formats, so i need to transform each response to canonical model before validate onComplete expression, how can i achieve this?
Thanks for your quick response!
I know that XSLT transformation is what i need to transform the response message, but the problem is i don't know where to put it. What i understand is the onComplete section needs a xpath expression from response message, but the three message have different xpath values.
for example:
Response 1:
<ns:getCustomerInfoResponse>
<ns:Status>
<ns1:Code>0</ns1:Code>
<ns1:Desc>SUCCESS</ns1:Desc>
</ns:Status>
</ns:getCustomerInfoResponse>
Response 2:
<v1:findByIdResponse>
<output>
<StatusCode>0</StatusCode>
<StatusDesc>OK</StatusDesc>
</output>
</v1:findByIdResponse>
What i need is transform two (or three) responses to unique canonical response before validate onComplete expression to something like:
<ns:response>
<status>
<code>0</code>
<desc>SUCCESS</desc>
</status>
</ns:response>
Thanks.
Thanks Ratha for your response.
Consider the following scenario:
In a bank there are three different systems: Credit System, CoreBanking System and CRM system.
I need to do something like "get all balances from all products", so, the request is the customer id, then the customer id is sent to CRM for obtaining all customer products. Depending of the product (Credit Card or Savings Account) it needs to send the customer id to Credit System or CoreBanking. Finally, each system will response and the ESB needs to response with both balances.
Hope you can help me with this use case!
Regards.
I don't think it is right to use aggregate mediator here, since you are receiving different responses from the service endpoints, which can not be correlated using xpath.
Aggregate mediator, which can be used along with clone/iterate mediators. Clone and iterate mediator is used to send same requests to multiple endpoint/such like scenarios.
My questions;
Are you sending same request to different endpoints and which are responding different type of responses? If so, it looks bit wrong, how you defined your services.
If you are sending different requests and getting different response, and want to aggregate( or create a new reponse) based on the responses which you received from your backend services, it will fall into service chaining pattern, which you can find in the ESB documentation.
Hope this is clear to you.
You can use XSLT mediator to get messages in to a unified format. please refer [1] for the XSLT mediator sample.
[1]. http://wso2.org/project/esb/java/3.0.1/docs/mediators/xslt.html
Thank You,
Dharshana.
This blog also explains your scenario with a sample...
If I understand you correctly, you want a combination of service chaining, transformation and iteration/aggregation.
So you start by sending the request to the CRM System, it will then respond with the different products, subdivided into Credit Card or Saving Account.
Then you could use two iterate mediators to split the response into the different requests for the two endpoints and collect the responses by using the aggregate or property mediator in the response sequences.
Now that you have the responses of the Credit System and CoreBanking service, you can start to transform (XSLT) and aggregate them to your response (balances).
Here you can find an example for service chaining and a bit of XSLT transformation.
Regards.
Related
My requirement is I will expose the ESB integration implementation as a REST API.
1) In the implementation part whenever they will call This ESB API it has to route based on content in the post request sent to ESB(this can be achieved by content based routing pattern ).
2) But on the Endpoint side Which is to be called by the ESB while routing based on content may vary means, if today there is 2 end point to call tomorrow it may rise to 5 like that how to apply changes are is there any solution. So, how to achieve this dynamic integration.
I have 4 ways to achieve this integration pattern.
1) Deploy files in the registry which has the endpoint in it and having the file name which is same as the content name(regex) sent in the payload for routing. Then by storing that name in property mediator and use concat function to read that file in another property mediator, and by pattern matching read the endpoint. Thus you can use that endpoint and achieve the dynamic content based routing.
2) Have separate sequence each one to call one endpoint and have the same name as the content name. The main sequence will call the sequence based on the content.
3)Store the content on which to be routed and endpoint in the RDBMS database then use DB lookup mediator to retrieve the endpoint based on this you can route.
4) I think this is best and suitable for integration scenario where tomorrow the endpoint may change( that is when the number of the endpoint is not fixed ) and each endpoint wants a different transformation of the payload(I mean XML to json or JSON to XML etc..).
First, use one API and store the content in property mediator and use that mediator to call another API which has the implementation to call the endpoint.
For example, if the content based on which routing has to happen has the payload like this
{ "content":"c1" }
Store the content in property mediator using name uri.var.address. Then create another API's which will have the implementation to call endpoint(For each endpoint create separate API's) and URI-Template of the API's should have content stored in the property mediator(same as payload request). While using send mediator to call these ENDPOINT implemented API's use http request having url of the API with /{uri.var.address} because to match the URI-template details.
I have been reading this documentation more than two weeks and it is still hard to understand some concepts.
Lets consider simple case. User makes request to our API then EI must call specific endpoint depending on requests body and show response.
Now there is the main problem on getting data of HTTP request.
I know that it could be accessed via Property Mediator, but this documentation does not help to understand anything.
if user makes GET request like this:
https://my-ei-domain.com:8280/myapi/mymethod?query1=1&query2=2
How it is possible to get values of query1 and query2
If user makes POST request with urlencoded form data how to get them?
If user makes POST request with JSON body like this:
{
"var1": "one",
"var2": 2,
"var3": {
"var3_var1": "two"
}
}
How to get values of these variables?
User makes POST request with XML body:
<body>
<var1>1</var1>
<var2>2</var2>
<var3>
<var1>3</var1>
</var3>
<body>
How to get these values?
Next problem. Sometimes users will send some variables inside Headers of requests. How to get them?
These cases are not described well in documentation. Even if they are, they just scattered across multiple pages.
if user makes GET request like this... . Using as described in
documentation URL Template or URI mapping
https://docs.wso2.com/display/EI611/Working+with+APIs
If user makes POST request with urlencoded form data how to get them... There is no another way to get data as described above. Actually Content-Type is used to identify how data transfered and I think (since ESB server use apache http core lib, widely used) will able to handle param values. Anyway that is easy to reproduce. Create rest service, send urlencode request and see how it works.
If user makes POST request with JSON body like this... Rules are described in documentation how to work with json in synapse engine https://docs.wso2.com/display/ESB480/JSON+Support (paragraph Accessing content from JSON payloads)
User makes POST request with XML body: to rest service ? to webservice? Anyway, xpath is commonly used to access certain parts of xml documents. But, synapse engine has to identify that xml document is received and parse it. Engine relies on Content-Type, details in here https://docs.wso2.com/display/ESB480/Working+with+Message+Builders+and+Formatters
Next problem. Sometimes users will send some variables inside Headers of requests. How to get them? In here how to read http headers in esb
Most of answers in documentation or easy to find by in web.
Your question is quite long and I can see you are requesting tutorials on how to achieve these. I hope the following Wso2 related tutorials will help you:
Enterprise Service Integration
Service Orchestration
Restful Integration
As an example let me explain the answers to a few of your questions:
To get information from a query like the following:
http://127.0.0.1:8280/pizzashop/api/menu/pizza?val=thin&type=crust
you may use property mediators like this:
<property name="Type" expression="$ctx:query.param.type"></property>
<property name="Val" expression="$ctx:query.param.val"></property>
WSO2 uses mediators to achieve most of the tasks. For example the payloadFactory mediator can be used to process the json and xml body and transform them. To process the following json
{ "payment":
{
"amount_lkr": "175.00",
"card_no": "1234-5678-9876-5432"
}
}
we can use payloadFactory mediator as follows:
<payloadFactory media-type="json">
<format>{"purchaseInformation": {"amount": "$1","cc": "$2"}}</format>
<args>
<arg evaluator="json" expression="$.payment.amount_lkr"></arg>
<arg evaluator="json" expression="$.payment.card_no"></arg>
</args>
</payloadFactory>
Similarly this mediator and others can be used to process xml as well in a POST request.
Please learn from the tutorials. The details are too broad to be explained in a single answer
I’m stuck with trying to connect to my SOAP API. The goal is to retrieve a quote via the “Getquote” function which is available in our webservice and use that quote in an application in Bubble.is. Therefore, I want to make it work through form-data so I can reuse the keys and values in Bubble. I get a succesfull quote through the raw method. See picture
Raw method:
You can see that all my fields are in the body so with the form-data method I put all the individual fields in key and value but I get the error message you see below.
Form data method:
Can someone see what I'm doing wrong? Excuses me for I am just starting. There might be some beginner mistakes in there. Thanks for the help!
SOAP encodes messages by using XML. Form data uses a completely different encoding, which the SOAP server doesn't understand, hence the error.
Although I've never used it, there is a Chrome extension called Boomerang that supports SOAP requests, and which may suit you better.
Why don't we have a GET call in SOAP?
We only send POST requests with SOAP.Why..?
In RESTful APIs, GET, POST, etc. are part of the "method call," so to speak.
However, in SOAP all of the information about the method call is specified in XML.
POST is just more practical for transmittng XML objects in the body of a HTTP request or response. The query string in a GET request would be awkward and has limitations.
However, SOAP 1.2 supports GET for certain requests. This means you can take advantage of caching responses.
SOAP is also not bound to any underlying transport architecture (like HTTP). That means it could be used on top of SMTP for example.
See the section on http binding for more info: https://www.w3.org/TR/soap12-part2/#soapinhttp
I've created a ColdFusion Web Service, but it's returning WDDX instead of SOAP. How do I make it return SOAP instead of WDDX?
Have the <cffunction> return an XML object, and have the "returnformat" parameter be set to "plain".
<cffunction name="GetData" returntype="xml" returnformat="plain">
For complex objects, you need to setup the CFCs correctly. Read: Using ColdFusion components to define data types for web services
update: Or, you can create the XML representation of your object yourself with <cfxml>, then return the XML object with returnType="xml" in cffunction.
You may check out coldbox's XMLConverter Plugin as code sample for converting built-in CF complex types into XML.
A CFC method with access=remote ought to return soap, rather than WDDX. I'm sure I've used this functionality for years. What I'm suspecting may be happening is that the content-type is based on the request a client makes. I would download Soap-UI and test http://your.server/yourCFC.cfc?wsdl to see whether SOAP-UI gets WDDX thrown back at it. If is does, I'm at a bit of a loss, but do report it here anyway and I'll take a further look.
If Soap-UI sees a proper response, take a look at the headers it's sending and compare them to the request you're making (possibly through the browser?)
You can also use Fiddler to record soap-ui traffic and compare that against any other source of requests.
The http request thing above may be completely off, but it's relatively easy to check and I think it's ringing a bell.
You may also want to check the return type of the function you're writing. In order for CF to generate a good WSDL, it needs to be able to extract metadata from the CFC you're returning.
A bit late to the game but were you hitting it as a plain HTTP request and not as with a SOAP packet?
For example were you doing this:
http://api.example.com/something.cfc?method=test&arg1=val1
instead of an actual SOAP request with envelope, headers, body, etc?
The HTTP request returns WDDX by default or JSON by specifying the returnformat, while a SOAP request will return data in the format you are seeking.