How to achieve the dynamic integration pattern in WSO2 ESB - wso2

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.

Related

how to send "messagebody" directly in api call to SQS queue via url without using postman?

i have api gateway with 3 simple backends:
2 basic api routes (/plus and /minus) backed by lambda functions
1 direct sqs queue (/sqs_send)
It means i can send via api call directly to my sqs queue.
2 lambda backend functions take 2 params 'a,b' from api call and add,subtract and show output.
https://86bwtlv5ya.execute-api.us-east-1.amazonaws.com/minus?a=10&b=20 # prints -10 in browser
https://86bwtlv5ya.execute-api.us-east-1.amazonaws.com/plus?a=10&b=20 # prints 30 in browser
The 3rd function is tricky for me. Via postman i managed to send directly to sqs like this via put request. Notice how i have to select "body" "raw" then input message. I did check the sqs queue - the msg from postman is there.
My question - what to type into my api gateway endpoint to send msg directly to sqs? Without using postman?
https://86bwtlv5ya.execute-api.us-east-1.amazonaws.com/sqs_send?mesagebody # what to type after sqs_send?
This did not work - returns {"message":"Not Found"}
https://86bwtlv5ya.execute-api.us-east-1.amazonaws.com/sqs_send?
Action=SendMessage&
MessageBody=This+is+a+test+message
Is it possible, my sqs_send api route does not work with parameters, because it is designed to only work with "messagebody" as per my settings? "Message attributes" is empty?
If I understood correctly, you want to call your API gateway endpoints by directly entering the URL into your browser's address bar.
Short answer:
Unfortunately you can't do this with your 3rd endpoint /sqs_send, because it is a PUT endpoint which the browser cannot call directly through the address bar.
Details:
Browsers usually support only HTTP GET and POST methods directly, through form submissions (which in turn is an HTML limitation, where form submissions only support these two methods). In GET method, parameters are appended to the end of the URL in the pattern example.com/?name1=value1&name2=value2. In POST method, parameters are included in the body of the request, so they're not visible in the URL itself. This means that you can only call GET endpoints by directly typing into the address bar of your browser. Your /plus and /minus are likely GET endpoints. POST endpoints must be called via HTML form submissions to include your parameters.
For calling other methods like PUT and DELETE (in addition to GET and POST), you will have to use XMLHttpRequest or the Fetch API, or some frontend framework method built around them. As your Postman screenshot shows, your third endpoint /sqs_send is a PUT, so you can't call it directly by entering the URL into the browser's address bar. If you must call it this way, you will have to convert your endpoint to a GET so that you can send your parameters via URL parameters.

Handling soap+msbin1 content type in Jmeter

I am trying to use Jmeter for performance testing of a WPF app that uses WCF Web Service. I see that the service is using msbin1 encoding format. Hence i am no able to make out what the request parameters are. How to handle this in Jmeter
In order to make the request you need to just add HTTP Header Manager and configure it to send Content-Type header with the value of soap-msbin1. In order to send the actual payload you can use i.e. HTTP Raw Request sampler.
If you need extended functionality, i.e. to be able to build requests from text and perform correlation of responses you will have to use the code from WCF-Binary-SOAP-Plug-In in JSR223 Test Elements and perform payload encoding/decoding using Groovy language

Encode webservice API url

I am using multiple webservices API from multiple clients.
I can see the URL in the network tab in the browser inspect. i don't want to expose the URL.
Is there any way to encode the URL to unread format?
From client side, no way. Maybe use a gateway url which does server-side call to "wanna be hidden" url and returns its result to the client ? But it wouldn't change the fact the output would be the same.
if you want to hide an url call from the client, don't do it client-side.
You have to change your design , essentially you need to put a proxy layer in between your client and actual API where the proxy can take a generic input with the encrypted url as the parameter something like
/Apiproxy/{encrypted url}
And the proxy can decrypt it and sent it to the actual u. You do have the complexity of managing the encryption key as well with this approach.
But why do you need this thing ?

wso2 esb endpoint can not be changed

I have some external URL (restful api) to be integrated.
Those URL have different prefixed URL with different parameter at url, for example:
www.abc.com/books
www.abc.com/book/11
www.abc.com/book/11/authors
When get response from those invocation, esb needs to convert response from one json format to our standard json format.
I plan to use esb javascript mediator to perform convert operation, but I didn't find any way to attach url parameters.
Any one have any idea?
I have used mediator by java code to implement it, but it is too heavy.
I am also looking into connector for another option.
I have got a solution by use url template. By this solution, I can change url according to template defined.
With this solution, I didn't need to write mediator or connector.

How To Know The Client Url in Wso2ESB sing property Mediator

i have two proxys . i wish to filter the Client url in second proxy means
my first proxy implemented and send some data to 2nd proxy.Its working fine But my wish i dont want allow any other service to use my proxy .In that case i need to filter based On the URL. We have option in ESb get-property('To') for know to url of target service but How we can know that Which client is calling me
`<property name="client-host" expression="get-property('From')"/>`
this property not working
even i defined in Client and target service also but its returning "null"
<property name="client-host" expression="get-property('To')"/>
this property returning me present service URl
But i need Client Url Who is calling me...
how could i define it and where can i define either in Client Or Target
http://docs.wso2.org/wiki/display/ESB460/Property+Mediator#PropertyMediator-PropertiesToFromActionFaultToReplyToMessageID
can you enable the ws-addressing module to your proxies and see that "from" property is working or not?
Generally from,to action properties are captured from transport receiver..
WS-addressing will capture same properties and if they are already available, ws-addressing will overwrite them...