Pass property from inSequence to outSequence - wso2

I'm sending a message with a Proxy to a HL7 TCP/IP port and get the response in the outSequence. But my problem is that all properties set in the inSequence are not anymore available. All of them are null. I tested with all the different scopes (transport, axis2, axis2-client), but none of them worked.
I saw in this post that it should be possible. Is the HL7 sender destroying the properties?
How can use my properties from the inSequence in the outSequence?
Example of my Proxy (get message from ActiveMQ JMS and sends to HL7 port 4000):
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" xmlns:hl7="http://wso2.org/hl7" xmlns:urn="urn:hl7-org:v2xml" name="demo_toHL7" transports="jms" startOnLoad="true" trace="disable">
<parameter name="transport.jms.Destination">demo_qFilter</parameter>
<parameter name="transport.jms.ConnectionFactory">queueBlocking</parameter>
<parameter name="transport.jms.DestinationType">queue</parameter>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>application/edi-hl7</default>
</rules>
</parameter>
<target faultSequence="rollbackSequence">
<inSequence>
<log level="full"/>
<property name="ClientApiNonBlocking" scope="axis2" action="remove"/>
<property name="testProperty" value="blabla" scope="transport"/>
<property name="messageType" value="application/edi-hl7" scope="axis2"/>
<property name="ContentType" value="application/edi-hl7" scope="axis2"/>
<send>
<endpoint>
<address uri="hl7://localhost:4000"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="custom">
<property name="PROPERTY" expression="get-property('transport','testProperty')"/>
</log>
</outSequence>
</target>
</proxy>
I'm using WSO2 ESB 4.0.3 and installed the HL7 Feature. As receiver I use the 7edit application.

Try with property scope as "default/synapse"
FiveO edit comment:
Try with property scope as "default":
Sending a transport property from the inSequence to the outSequence (on behalf of the default scope):
<inSequence>
...
<property name="myPropertyInTransport" value="myValue" scope="transport"/>
<property name="myPropertyInDefault" expression="get-property('transport','myPropertyInTransport')" scope="default"/>
...
</inSequence>
<outSequence>
...
<property name="myPropertyInTransport" expression="get-property('default', 'myPropertyInDefault')" scope="transport"/>
<!-- Now myProperty is also available in the outSequence -->
...
</outSequence>

Related

In wso2 esb i can send but i am not able to listen to websocket

In wso2 ESB, I am able to send data to WebSocket but I am not able to receive data.
I tried this with rest api of wso2 esb.
<?xml version="1.0" encoding="UTF-8"?>
<api context="/test" name="test" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST">
<inSequence>
<property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
<property name="FORCE_SC_ACCEPTED" scope="axis2" type="STRING" value="true"/>
<log level="full">
<property name="message" value="********************************************input**********************"/>
</log>
<send>
<endpoint>
<http method="post" uri-template="ws://localhost:8080/websocket/server"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</resource>
</api>
outsequence:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="outflowDispatchSeq" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<log level="full">
<property name="message" value="************************************************"/>
</log>
</sequence>
with the above API, I am able to send data to the server as shown in below image.
Http request from postman.
But as shown in below image of the console, the response which i am getting is empty as no body present.
If I use proxy service with content-type mentioned as in esb documentation(link) in websocket server i am getting exception
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="dispatchSeq" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<property name="OUT_ONLY" value="true"/>
<property name="FORCE_SC_ACCEPTED" scope="axis2" type="STRING" value="true"/>
<property name="websocket.accept.contenType" scope="axis2" value="text/plain"/>
<send>
<endpoint>
<address uri="ws://localhost:8080/websocket/server"/>
</endpoint>
</send>
</sequence>
axis2.xml websocket configuration is:
<transportSender name="ws" class="org.wso2.carbon.websocket.transport.WebsocketTransportSender">
<parameter name="ws.outflow.dispatch.sequence" locked="false">outflowDispatchSeq</parameter>
<parameter name="ws.outflow.dispatch.fault.sequence" locked="false">outflowFaultSeq</parameter>
</transportSender>
So how to send and receive the data from websocket

Guaranteed Delivery of Messages with Active MQ and WSO2 EI

Issue: i have a proxy service which consumes only XML message, but sometimes if we are getting XML message with not proper format,just syntax error,our proxy should send that message to a different queue,the message should not loss.
i have followed the below link but unable to get the expected output
https://www.yenlo.com/blog/guaranteed-message-deliveries-part-3-monitoring-the-redelivery-policy
Below is my proxy:
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="RollbackProxy" startOnLoad="true" transports="jms" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<log description="" level="full">
<property name="****************" value="******************************"/>
</log>
</inSequence>
<outSequence/>
<faultSequence>
<property name="SET_ROLLBACK_ONLY" scope="axis2" type="STRING" value="true"/>
<log category="ERROR" level="full">
<property expression="$ctx:ERROR_CODE" name="error_code"/>
<property expression="$ctx:ERROR_MESSAGE" name="error_message"/>
<property expression="$ctx:ERROR_DETAIL" name="error_detail"/>
</log>
</faultSequence>
</target>
<parameter name="transport.jms.Destination">QueueName</parameter>
<parameter name="transport.jms.ContentType">
<rules xmlns="">
<jmsProperty>contentType</jmsProperty>
<default>application/xml</default>
</rules>
</parameter>
<parameter name="transport.jms.ConnectionFactory">myQueueConnectionFactory</parameter>
</proxy>
axis2.xml and activemq.xml i have properly updated.
we are using active MQ.
Can somebody guide me on this?
Thanks in Advance

wso2/synapse service chaining: assign response from SOAP request as intput to another request

My desired sequence is the following:
Read message from queue
Transform
Make an SOAP call
Output SOAP response to another queue
Steps 1,2,3 work fine but when the message sent in Step 4, that I'm intending to contain the SOAP response, is empty. What am I doing wrong?
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="JmsToWsdlJms" transports="https,http,jms" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<enrich>
<source type="body" clone="true"/>
<target type="property" property="jms_body_text"/>
</enrich>
<property name="jms_body_text"
expression="get-property('jms_body_text')"
scope="default"/>
<xslt key="jmsMsgToSoapMsg_xslt">
<property name="jms_text" expression="get-property('jms_body_text')"/>
</xslt>
<log level="full">
<property name="After transformation" value="****"/>
</log>
<send>
<endpoint key="axisStockQuote"/>
</send>
<log level="full">
<property name="After callout" value="****"/>
</log>
<property name="OUT_ONLY" value="true"/>
<send>
<endpoint key="jmsQueue2"/>
</send>
</inSequence>
</target>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>text/plain; charset=ISO-8859-1</default>
</rules>
</parameter>
<parameter name="transport.jms.DestinationType">queue</parameter>
<parameter name="transport.jms.Destination">cn=tro_Q_JMS1</parameter>
</proxy>
You can use 'send receive' instead of the send mediator. Something like,
<send receive="jmsQueue2Sequence">
<endpoint key="axisStockQuote"/>
</send>
So that the response of axisStockQuote will be sent to the jmsQueue2Sequence. Refer [1] for more info.
[1] https://docs.wso2.com/display/ESB481/Send+Mediator

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/