WSO2 Payload Mediator: how to handle optional arguments - wso2

I'm creating a proxy service to transform a SOAP request into REST call but I'm unable to handle optional SOAP input parameters. Is there a way to check if a SOAP parameter exists before passing to REST into payload Mediator?
Regards

Related

WSO2 ESB - How does Passthrough handle empty payloads

Hi I would like to know if the WSO2 ESB stalls whenever consecutive ping requests are made (without any payload). Is there a way to capture such scenario.
WSO2 ESB does not stall when the incoming payload is empty. It will internally represent it as a soap envelope with an empty body.

wso2 using clone and aggregate with datamapper

So I am using Clone Mediator and Aggregate Mediator to get the two(2) response from the API in a single request. But the problem is that the first request returns an error from DataMapper Mediator (http://pastebin.com/7P43ZbAa) and the second request returned my expected response (http://pastebin.com/2WbCvi9z) without any errors.
Here's my api config
http://pastebin.com/2ytGEkFk

WSO2 API Message Mediation based on accept headers

I am using WSO2 Api Manager as a proxy between a client and the server. The server sends XML responses that I successfully converted to a JSON response with a custom PayloadFactory message mediation. Problem that I now am facing is the following: How do I mediate based on the accept headers of a request?
When I have in the header of a request:
Accept application/json
I want to use my mediator to convert the response from the server to JSON, but when I have
Accept text/xml or application/xml
I don't want to use my mediator and just forward the response as is.
Edit:
Basicly the only thing a really need is to save my "Accept ... " header. I can forward it to the server, but the server doesn't do anything with it. Are there global variables or something that I can use per proxy request?
Any advice will be appreciated.
You can use Filter mediator or Switch mediator to do a if-then-else kind of operations inside the insequence and implement your first requirement. You can get the header using synapse xpath variables.
You can define a custom sequence and add it to the api
for the second question, you can use property mediator to define values and use them later. set the 'Scope' parameter according to your need

wso2:esb: What is the basic difference between call mediator and send mediator

Anybody would please through some light on difference between call and send mediator and what use cases these two mediators are used.
Send mediator - used to send messages out of Synapse to some endpoint. Then the response is returned to the OutSequence where you can send it back to the client
Use cases - When you only need to send a message to one back end and return the response back to the client.
Call mediator - Also used to send messages out of the Synapse to some endpoint, but the response does not come to the OutSequence. When we send a request using the call mediator, the response will arrive to the mediator that is placed right after the call mediator.So this will allow us to specify all the service invocations one after the other in a chain within a single sequence
Use cases - Service chaining. i.e.- Vehicle license renewal service
Another characteristic is that the callout mediator is blocking, send mediator and call mediator are not blocking. This answer is in regards to WSO2 versions until 4.8.0

How to validate input and output messages in proxy service against wsdl

Is there any way to validate input and output messages in proxy service against specific wsdl?
Have a situation, when proxy generates invalid output message, so i want to catch this inside my proxy just before responding to client.
Also i want to check if input message is valid.
You can use a tool like SoapUI to validate scenario like this. You can generate a test using particular wsdl. And you can use tool like tcpmon to validate the message going between proxy and the particular endpoint.
As a example use one tcpmon listening to out port to the proxy and redirect it to the actual port.
You can find soapui from [1] and if your using wso2 ESB the tcpmon is available at /bin directory and you can start it using
sh wso2esb-4.5.0/bin/tcpmon.sh
By looking at the message passing through tcpmon you can validate the message going out from your proxy.
[1]. http://sourceforge.net/projects/loadui/files/latest/download?source=files
You can validate the payload of the wso2 esb proxy using the Validate mediator.
Example,
<validate source="//xpath_of_element_to_validate">
<schema key="local_entry_name_of_your_schema_file"/>
<on-fail>
*This part contains the code to handle validation failure*
</on-fail>
</validate>
This Validate mediator can be used anywhere in the proxy. To validate the request, use it as the first line and to validate the response, use it before the respond mediator
You can refer the below link for more details,
https://docs.wso2.com/display/ESB490/Validate+Mediator
Hope this helps!!
Thanks!!