why call is not working in wso2 esb - wso2

I have a problem with wso2 esb.
I wrote a proxy and in that I call an endpoint to do some changes on original input. but the log before call and after call is the same(it should be different). It seems the call is not working at all.when I send respone to outsequence it is null. Can any one say why this happen? (I have tested my endpoint in soupUI)
this is my proxy:
<inSequence>
<property name="transport.vfs.ReplyFileName" value="GET" scope="transport"/>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<smooks config-key="smooks-csv1">
<input type="text"/>
<output type="xml"/>
</smooks>
<iterate continueParent="true"
preservePayload="true"
attachPath="//csv-set"
expression="//csv-set/search"
sequential="true">
<target>
<sequence>
<xslt key="gov:/first.xsl"/>
<xslt key="gov:/second.xsl"/>
**<log level="full"/>
<call blocking="true">
<endpoint>
<address uri="MyEndPiont"/>
</endpoint>
</call>
<log level="full"/>**
</sequence>
</target>
</iterate>
<respond/>
</inSequence>
<outSequence>
<aggregate>
<completeCondition>
<messageCount min="0" max="100"/>
</completeCondition>
<onComplete expression="//Guest">
</onComplete>
</aggregate>
</outSequence>

Try this. List of changes:
Removed respond mediator.
Replaced call by send.
Added send in out sequence.
<inSequence>
<property name="transport.vfs.ReplyFileName" value="GET" scope="transport"/>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<smooks config-key="smooks-csv1">
<input type="text"/>
<output type="xml"/>
</smooks>
<iterate continueParent="true"
preservePayload="true"
attachPath="//csv-set"
expression="//csv-set/search"
sequential="true">
<target>
<sequence>
<xslt key="gov:/first.xsl"/>
<xslt key="gov:/second.xsl"/>
<log level="full"/>
<send>
<endpoint>
<address uri="MyEndPiont"/>
</endpoint>
</send>
</sequence>
</target>
</iterate>
</inSequence>
<outSequence>
<aggregate>
<completeCondition>
<messageCount min="0" max="100"/>
</completeCondition>
<onComplete expression="//Guest">
</onComplete>
</aggregate>
<send />
</outSequence>

Try blocking="false". Please note that making this change does not make the call mediator is asynchonus. It's synchronous regardless of whether blocking is true or false. Blocking is just an implementation detail.
The Call mediator is used to send messages out of the ESB to an
endpoint. You can invoke services either in blocking or non-blocking
manner.
When you invoke a service in non-blocking mode, the underlying worker
thread returns without waiting for the response. In blocking mode, the
underlying worker thread gets blocked and waits for the response after
sending the request to the endpoint. Call mediator in blocking mode is
very much similar to the Callout mediator.
In both blocking and non-blocking modes, Call mediator behaves in a
synchronous manner. Hence, mediation pauses after the service
invocation and resumes from the next mediator in the sequence when the
response is received. Call mediator allows you to create your
configuration independent from the underlying architecture.
Quoted from https://docs.wso2.com/display/ESB500/Call+Mediator

Related

Can I invoke a web service using call mediator in wso2 esb?

<?xml version="1.0" encoding="UTF-8"?>
<sequence name=SEQUENCE trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<iterate expression=EXPRESSION sequential="true" xmlns:ns="http://org.apache.synapse/xsd">
<target>
<sequence>
<log level="full">
<property expression="$body/*" name="Test within iterate"/>
</log>
<call>
<endpoint>
<http method="POST" uri-template=URI TEMPLATE
</endpoint>
</call>
<log>
<property name="After CALL" value="response"/>
</log>
</sequence>
</target>
</iterate>
<aggregate>
<completeCondition>
<messageCount max="-1" min="-1"/>
</completeCondition>
<onComplete expression="$body/*" sequence="OutSequenceforData"
xmlns:ns="http://org.apache.synapse/xsd"
xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s12="http://www.w3.org/2003/05/soap-envelope"/>
</aggregate>
<send/>
<log level="full">
<property expression="$body/*" name="After Aggregate" xmlns:ns="http://org.apache.synapse/xsd"/>
</log>
</sequence>
I am trying to invoke a web service using call mediator. But I do not see any log about the call in the wso2 logs. The goal is to display the data from a file in the web service.
Yes you can, after the Call mediator put a Log mediator.
<log level="full" xmlns="http://ws.apache.org/ns/synapse"/>

WSO2 iterate calling endpoint until correct response

I'm working with wso2 ESB 4.8.1
My complete functionality is:
Step one:
I make a call to a service that respond me with a processId (Asynchcronous)
The service make the work asociated to that processId
Step two:
I have to iterate calling the service with the processId Until a response that indicate me that process has finished and return me the result
I'm having problems with step two implementation.
You can store the response with the process id into a Message Store.
You define a Message Processor (a scheduled message forwarding processor) that consume messages from this store and send them into a proxy service (defined inside the same ESB)
In this proxy service :
you call your service with the process id
you analyse it's response in this proxy outSequence and decide to return it if it's OK (so, the message processor will execute the reply.sequence and delete the message from the store) or return an error if not (the message processor will execute the fault.sequence and let the message in the store so, it will retry it the next time)
Thanks you very much I'll try your solution.
I have make some advances with a secuence that check if the processId has finished and if not the secuence call it own (recursion), I'm testing this alternative, I put the code (some thinks are hardcode but the important is the idea)
<resource methods="GET" uri-template="/test2">
<inSequence>
<log>
<property name="***** IN" value="Estoy en el GET /recursivetest1/test2"></property>
</log>
<call>
<endpoint name="uploadServlet">
<!-- this is the request that return the processId -->
<http method="get" uri-template="http://localhost:1234/ProyectoWebMultipartForm/UploadServlet?fase=escaneo"></http>
</endpoint>
</call>
<log>
<property name="data_id" expression="json-eval($.data_id)"></property>
</log>
<property name="escaneo" expression="json-eval($.data_id)"></property>
<sequence key="iterate_calls2"></sequence>
<send></send>
</inSequence>
<outSequence>
</outSequence>
</resource>
</api>
/////////////////
<sequence xmlns="http://ws.apache.org/ns/synapse" name="iterate_calls2" trace="disable">
<call>
<!-- this is the request that check if the processId has finished-->
<endpoint name="uploadServlet">
<http method="get" uri-template="http://localhost:1234/ProyectoWebMultipartForm/UploadServlet?fase=chequeo"></http>
</endpoint>
</call>
<property xmlns:ns="http://org.apache.synapse/xsd" name="resultado" expression="json-eval($.scan_results.scan_all_result_a)"></property>
<filter xmlns:ns="http://org.apache.synapse/xsd" source="get-property('resultado')" regex="Clean">
<then>
<log level="full">
<property name="MESSAGE" value="No hay virus"></property>
</log>
</then>
<else>
<property name="mensaje" expression="json-eval($.mensaje)"></property>
<filter source="get-property('mensaje')" regex="Escaneo sin finalizar">
<then>
<!-- the processId has not finished, I call again to the sequence, recursion-->
<log level="full">
<property name="MESSAGE" value="El escaneo no ha finalizado antes del sleep"></property>
</log>
<script language="js">
<![CDATA[java.lang.Thread.sleep(200);]]></script>
<log level="full">
<property name="MESSAGE" value="El escaneo no ha finalizado despues del sleep"></property>
</log>
<sequence key="iterate_calls2"></sequence>
</then>
<else>
<!-- the processId has finished, I have end-->
<log level="full">
<property name="MESSAGE" value="No hay virus"></property>
</log>
</else>
</filter>
</else>
</filter>
</sequence>

WSO2ESB Parallel SOAP calls

I have the following problem:
Develop a WSDL Based Proxy that calls several different SOAP Web services in parallel and returns the responses:
<inSequence>
<log level="full"/>
<iterate xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:agg="http://www.test.ro/aggregate"
preservePayload="true"
attachPath="//soapenv:Body"
expression="//agg:AggregateRequest/agg:messageRequest">
<target>
<sequence>
<property name="messageId"
expression="//soapenv:Body/agg:messageRequest/agg:messageId[node()]"/>
<property name="endpoint"
expression="//soapenv:Body/agg:messageRequest/agg:endpoint[node()]"/>
<xslt key="CleanPayload" source="/"/>
<send>
<endpoint key="MirrorEndpoint"/>
</send>
</sequence>
</target>
</iterate>
</inSequence>
<outSequence>
<property name="resp" scope="default">
<agg:AggregateResponse xmlns:agg="http://www.test.ro/aggregate"/>
</property>
<aggregate>
<completeCondition timeout="10">
<messageCount min="-1" max="-1"/>
</completeCondition>
<onComplete xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
expression="$body/*"
enclosingElementProperty="resp">
<log level="full"/>
<send/>
</onComplete>
</aggregate>
</outSequence>
My challenges are:
how do I pass the messageId from inSequence to outSequence so I can match the response to the request (similar to local environment from Message Broker)
how do I set the endpoint key with the text from agg:endpoint
I know this may be a newbie question but I'm having a hard time finding good tutorials on this topic.
Thank you
When you set a property (scope default) inside the In Sequence, you can find back it's value inside the Out Sequence.
Set this property inside your In Sequence :
<property name="IN_MESSAGE_ID" expression="get-property('MessageID')"/>
you can use get-property('IN_MESSAGE_ID') in your Out Sequence
If you want to send a message to a dynamic address, you can set "To" header and use send mediator :
<header name="To" expression="get-property('MY_DESTINATION')"/>
<send/>
Try setting the messageId as a HTTP header property,
<header name="MessageId" value="0001" scope="transport"/>
And retrieve this header in the outSequence
<property name="MessageId" expression="get-property('MessageId')"/>
I havnt tested this out, so give a feedback on whether it works

Callout mediator doe'snot giving any response in WSO2 ESB 4.7.0

While I am using call out mediator in wso2 esb , with DSS Endpoint I am
getting the request only, I am not getting response, even I put log in
the out sequence. Here I am sending my proxy service.
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="Binaryformat"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="messageType" value="application/json" scope="axis2"/>
<property name="ContentType" value="application/json" scope="axis2"/>
<log level="full">
<property name="M1" value="*************Callout PROXY*************"/>
</log>
<callout serviceURL="http://192.168.1.201:9769/services/emp_DataService/">
<source type="envelope"/>
<target key="response"/>
</callout>
<log level="full">
<property name="Status" expression="get-property('response')"/>
</log>
<header name="To" action="remove"/>
<property name="RESPONSE" value="true"/>
<!--<property name="OUT_ONLY" value="true"/>-->
<send/>
</inSequence>
<outSequence>
<log level="full">
<property name="Status" expression="get-property('response')"/>
</log>
<payloadFactory media-type="xml">
<format>
<response>outonly</response>
</format>
<args/>
</payloadFactory>
<property name="OUT_ONLY" value="true"/>
<send/>
</outSequence>
</target>
</proxy>
I think you have configured callout mediator wrongfully. Check for the callout mediator sample here
http://docs.wso2.org/display/ESB470/Sample+430%3A+Simple+Callout+Mediator+for+Synchronized+Web+Service+Invocation
As well as OUT-ONLY set to "true" mean on a message to indicate that no response message is expected for it once it is forwarded from the ESB. you can read more about OUT_ONLY and other properties from here http://docs.wso2.org/display/ESB470/Generic+Properties
callout mediator is synchronous, it will return the response in the same sequence (your inSequence, by doing a blocking call) : your outSequence is unnecessary.
however, you should add a faultSequence to log any error
you should use tcpmon (launch tcpmon in ESB_HOME/bin) between ESB and your endpoint to verify request content going to your service and verify if you obtain a response from your service.

WSO2 ESB - transform a HTTP 202 accepted response

The Endpoint_BPS_CreateCaseService/UpdateCaseService endpoints below both point to one-way BPEL services running on WSO2 BPS. WSO2 BPS returns a HTTP 202 accepted message instantly when they are invoked.
The client application that I am using will throw a fault if it does not get a valid SOAP envelope as a response so I'm going to use a proxy service in ESB to wrap around the BPEL process.
How do I use a WSO2 ESB proxy service to forward a SOAP envelope to Endpoint_BPS_* below and then return a SOAP envelope response to my client app?
I also want to execute the faultSequence "ProcessFault" if either endpoint is unavailable or times out. I previously used the OUT_ONLY to get around the response issue above but it means I can't detect endpoint problems. Unless it is possible to do both somehow?
Another thing I've tried is cloning the message but this was a bit messy.
Any help greatly appreciated
<proxy xmlns="http://ws.apache.org/ns/synapse" name="BPSProxyService" transports="https,http" statistics="disable" trace="enable" startOnLoad="true">
<target faultSequence="ProcessFault">
<inSequence>
<log level="full">
<property name="MESSAGE" value="BEGIN BPSProxyService" />
</log>
<switch source="//*[local-name()='Operation']">
<case regex="create">
<send>
<endpoint key="Endpoint_BPS_CreateCaseService" />
</send>
</case>
<case regex="update">
<send>
<endpoint key="Endpoint_BPS_UpdateCaseService" />
</send>
</case>
</switch>
</inSequence>
<outSequence>
<property name="HTTP_SC" value="200" scope="axis2" />
<class name="esb.mediators.InjectSOAPEnvelope" />
<log level="full">
<property name="MESSAGE" value="END BPSProxyService" />
</log>
<send />
<drop />
</outSequence>
</target>
<publishWSDL key="common/bpsproxyservice/bpsproxyservice.wsdl">
<resource location="schema.xsd" key="common/schema_v2.xsd" />
</publishWSDL>
</proxy>
When you receive a 'HTTP/1.1 202 Accepted' response from your backend like BPS in the outSequence of your Proxy Service, then you need the <property name="SC_ACCEPTED" value="false" scope="axis2"/> statement to modify the '202'-response into something else.
Example:
<property name="SC_ACCEPTED" value="false" scope="axis2"/>
<property name="HTTP_SC" value="200" scope="axis2"/>
<payloadFactory media-type="xml">
<format>
<response>
<result>OK</result>
</response>
</format>
<args/>
</payloadFactory>
<send/>
The response is transformed into 'HTTP/1.1 200 OK' with a response message.
Add the "FORCE_SC_ACCEPTED" parameter with the "OUT_ONLY" in the inSequence of the proxy service as follows.
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2" type="STRING"/>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
For more information use the following article:
http://mohanadarshan.wordpress.com/2013/05/05/out_only-scenario-in-proxy-service-wso2-esb/