WSO2 EI How to Send HL7 message (extract from XML SOAP) - wso2

how can I extract RAW HL7message from XML SOAP (taken from DB) and use endpoint to send it to HL7://localhost:20101 server ?
I have this message body:
<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<row xmlns="SERVICE_HL7IN">
<DATA1>
MSH|^~\&|||||20210414014542.151+0200||MDM^T04^MDM_T02|401|T|2.5
</DATA1>
</row>
</soapenv:Body>
and I need to send this to endpoint:
MSH|^~\&|||||20210414014542.151+0200||MDM^T04^MDM_T02|401|T|2.5
Here is the sequence:
<sequence>
<log level="custom">
<property expression="$body" name="outbod"/>
</log>
<property expression="//xsi:row/xsi:DATA1" name="sendmsg" scope="default" type="STRING"/>
<log level="custom">
<property expression="get-property('sendmsg')" name="outb"/>
</log>
<property name="HL7_RESULT_MODE" scope="axis2" type="STRING" value="ACK"/>
<property expression="get-property('sendmsg')" name="body" scope="axis2" type="STRING"/>
<payloadFactory media-type="text">
<format>
$1
</format>
<args>
<arg expression="get-property('sendmsg')">
</arg>
</args>
</payloadFactory>
<property name="messageType" scope="axis2" type="STRING" value="application/edi-hl7"/>
<property name="contentType" scope="axis2" type="STRING" value="application/edi-hl7"/>
<log level="full" />
<send>
<endpoint>
<address uri="hl7://localhost:20101"/>
</endpoint>
</send>
</sequence>
Any help or advice is appretiated

Related

WSO2 ESB how to sending array list empty error

I Configurate url like:
https://htygnfgvsccl.com:6753/intellige/vehicle/getAlerts
this url some times getting data like
{
"alertsList": [
{
"vehicleNo": "45342",
"alertName": "Stop Skipped",
"depotName": "akividu"
},
{
"vehicleNo": "674894",
"alertName": "Stop Skipped",
"depotName": "guntur"
}
]
}
but some times getting data like
{
"alertsList": []
}
every time response code is 200 but how to send with error message in the case of alertsList empty
vehiclegetAlertsapi
<?xml version="1.0" encoding="UTF-8"?>
<api context="/intellige/vehicle/getAlerts" name="vehiclegetAlertsapi" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET">
<inSequence>
<property description="http" name="HTTP_SC" scope="axis2" type="STRING" value="404"/>
<log level="full"/>
<send>
<endpoint key="vehiclegetAlertsendpoint"/>
</send>
</inSequence>
<outSequence>
<switch source="get-property('axis2','HTTP_SC')">
<case regex="200">
<log description="200log" level="custom">
<property expression="$ctx:ERROR_CODE" name="200reserrorcode"/>
</log>
<send/>
</case>
<default>
<log description="reslog" level="custom">
<property expression="$ctx:ERROR_CODE" name="reserrorcode"/>
<property expression="$ctx:ERROR_MESSAGE" name="reserrormessage"/>
<property expression="get-property('axis2','HTTP_SC')" name="reshttpsc"/>
</log>
</default>
</switch>
<clone continueParent="true">
<target>
<sequence>
<sequence key="vehiclegetAlertsmail"/>
</sequence>
</target>
</clone>
<send/>
</outSequence>
<faultSequence>
<switch source="get-property('axis2','HTTP_SC')">
<case regex="200">
<log description="200log" level="custom">
<property expression="$ctx:ERROR_CODE" name="200reserrorcode"/>
</log>
</case>
<default>
<log description="reslog" level="custom">
<property expression="$ctx:ERROR_CODE" name="reserrorcode"/>
<property expression="$ctx:ERROR_MESSAGE" name="reserrormessage"/>
<property expression="get-property('axis2','HTTP_SC')" name="reshttpsc"/>
</log>
</default>
</switch>
<clone continueParent="true">
<target>
<sequence>
<sequence key="vehiclegetAlertsmail"/>
</sequence>
</target>
</clone>
<send/>
</faultSequence>
</resource>
</api>
vehiclegetAlertsendpoint
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="vehiclegetAlertsendpoint" xmlns="http://ws.apache.org/ns/synapse">
<http method="get" uri-template="https://htygnfgvsccl.com:6753/intellige/vehicle/getAlerts "/>
</endpoint>
vehiclegetAlertsmail:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="vehiclegetAlertsmail" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<log level="custom">
<property name="status" value=" vehileget alert Details Sending mail"/>
</log>
<property expression="get-property('axis2','HTTP_SC')" name="ErrorMessage" scope="default" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<property name="ContentType" scope="axis2" type="STRING" value="text/plain"/>
<property name="Subject" scope="transport" type="STRING" value="vehileget alert api not working"/>
<property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
<property name="FORCE_SC_ACCEPTED" scope="axis2" type="STRING" value="true"/>
<payloadFactory media-type="json">
<format>{"vehileget alert api not working":"$1"}</format>
<args>
<arg evaluator="xml" expression="$ctx:ErrorMessage" xmlns:ns="http://org.apache.synapse/xsd"/>
</args>
</payloadFactory>
<call>
<endpoint key="vehiclegetAlertsmailid"/>
</call>
<drop/>
</sequence>
vehiclegetAlertsmailid:
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="vehiclegetAlertsmailid" xmlns="http://ws.apache.org/ns/synapse">
<recipientlist>
<endpoint>
<address uri="mailto:aisha#gmail.com"/>
</endpoint>
</recipientlist>
</endpoint>
get 200 response code send the data automatically in case if any other reponse to send the mail my mail id ,prsent my problem is my rest url some time total data like alertsList with data comming some times only alertsList comming not comming data that case how to send mail

No password supplied by the callback handler for the user [wso2]

I have a proxy service inlclued a sequence.
I process for authentication for proxy service with tag
<policy key="gov:/testPolicy"/>
<enableSec/>
In this sequence contain iterate mediator.
When call proxy service with authentication by soapUI then not reponse for client and have a error Unexpected error sending message back {org.apache.synapse.core.axis2.Axis2Sender} org.apache.axis2.AxisFault: No password supplied by the callback handler for the user : "wso2carbon"
If have not iterate mediator then have not error
This sequence
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="SendReceiveQueue" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<property expression="get-property('Edxml_Organ_Id')" name="senderUnitId" scope="default" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
<property expression="get-property('Edxml_Type')" name="applicationType" scope="default" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
<property expression="get-property('Edxml_Record_Code')" name="recordCode" scope="default" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
<property expression="$ctx:data_original" name="messagePl" scope="default" type="STRING" xmlns:edXML="http://www.mic.gov.vn/TBT/QCVN_102_2016" xmlns:ns="http://org.apache.synapse/xsd"/>
<property expression="$body" name="messagePlBody" scope="default" type="STRING" xmlns:edXML="http://www.mic.gov.vn/TBT/QCVN_102_2016" xmlns:ns="http://org.apache.synapse/xsd"/>
<property name="QUEUE_ACTION_TYPE" scope="default" type="STRING" value="SENDER"/>
<log level="custom">
<property expression="get-property('messagePl')" name="messagePllogging" xmlns:ns="http://org.apache.synapse/xsd"/>
<property expression="get-property('messagePlBody')" name="messagePlloggingBody" xmlns:ns="http://org.apache.synapse/xsd"/>
</log>
<iterate expression="$ctx:abc//edXML:To" id="abc" sequential="true" xmlns:edXML="http://www.mic.gov.vn/TBT/QCVN_102_2016" xmlns:ns="http://org.apache.synapse/xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<target>
<sequence>
<log level="custom">
<property name="goi DSS" value="-------------------------------------------"/>
<property expression="//edXML:To/edXML:OrganId/text()" name="queue name"/>
</log>
<payloadFactory media-type="xml">
<format>
<p:getQueueId xmlns:p="http://ws.wso2.org/dataservice">
<xs:in_unitId xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:in_unitId>
<xs:in_b2bType xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:in_b2bType>
</p:getQueueId>
</format>
<args>
<arg evaluator="xml" expression="//edXML:To/edXML:OrganId/text()"/>
<arg evaluator="xml" expression="syn:get-property('Edxml_Type')"/>
</args>
</payloadFactory>
<call blocking="true">
<endpoint>
<address uri="http://cqdt-app3:8280/services/validateData"/>
</endpoint>
</call>
<property expression="//x:returnCode/x:MessageQueueId/text()" name="queue_name" scope="default" type="STRING" xmlns:x="http://ws.wso2.org/dataservice"/>
<log level="custom">
<property name="lay xong tu dss" value="-------------------------------------------"/>
<property expression="$ctx:queue_name" name="ten queue lay ra"/>
</log>
<class name="com.vsc.ReceiveQueue">
<property name="password" value="admin"/>
<property name="queueName" value="testQueue1"/>
<property name="CF_NAME_PREFIX" value="connectionfactory."/>
<property name="CF_NAME" value="QueueConnectionFactory"/>
<property name="QPID_ICF" value="org.wso2.andes.jndi.PropertiesFileInitialContextFactory"/>
<property name="CARBON_DEFAULT_HOSTNAME" value="cqdt-app3"/>
<property name="QUEUE_NAME_PREFIX" value="queue."/>
<property name="userName" value="admin"/>
<property name="CARBON_CLIENT_ID" value="carbon"/>
<property name="CARBON_DEFAULT_PORT" value="5675"/>
<property name="CARBON_VIRTUAL_HOST_NAME" value="carbon"/>
</class>
<log level="custom">
<property name="put xong vao queue" value="-------------------------------------------"/>
<property expression="$ctx:queue_name" name="ten queue ban xong"/>
</log>
<payloadFactory media-type="xml">
<format>
<response>
<result>SUCCESS</result>
</response>
</format>
<args/>
</payloadFactory>
<property name="RESPONSE" scope="default" type="STRING" value="true"/>
<property name="messageType" scope="axis2" type="STRING" value="application/xml"/>
<property action="remove" name="NO_ENTITY_BODY" scope="axis2"/>
<header action="remove" name="To" scope="default"/>
<send/>
</sequence>
</target>
</iterate>
<property name="RESPONSE" scope="default" type="STRING" value="true"/>
<header action="remove" name="To" scope="default"/>
<log level="custom">
<property expression="get-property('messagePl')" name="1111555555555555555555555555551111111111111111111111111111111-------------------------------" xmlns:ns="http://org.apache.synapse/xsd"/>
</log>
</sequence>
Please help me!
Have you tried applying the policy on the endpoint directly?
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="TQBsEndpoint">
<address uri="http://cqdt-app3:8280/services/validateData" format="soap11">
<enableSec policy="gov:testPolicy"/>
</address>
</endpoint>

WSO2 ESB with DSS integrated doesn't response JSON

I have a WSO2 ESB server with DSS features installed. When I invoke a REST service with "accept: application/json" in request header, I don't receive JSON response, only XML.
Best, Ivan
In this API, to get the response in JSON, I use these two properties:
<property name="Accept" value="application/json" scope="transport" type="STRING"/>
<property name="messageType" value="application/json" scope="axis2"/>
You can see the implementation here
<api xmlns="http://ws.apache.org/ns/synapse" name="showById" context="/getById">
<resource methods="POST GET" uri-template="/getEmployeeXML/{Id}">
<inSequence>
<property name="getId" expression="get-property('uri.var.Id')" scope="default" type="STRING"/>
<log>
<property name="ID" expression="get-property('getId')"/>
</log>
<property name="Accept" value="application/json" scope="transport" type="STRING"/>
<property name="messageType" value="application/json" scope="axis2"/>
<payloadFactory media-type="xml">
<format>
<p:getEmployeeXML xmlns:p="arce.farmacy">
<xs:Id xmlns:xs="arce.farmacy">$1</xs:Id>
</p:getEmployeeXML>
</format>
<args>
<arg evaluator="xml" expression="get-property('getId')"/>
</args>
</payloadFactory>
<property name="Action" value="urn:getEmployeeXML" scope="transport" type="STRING"/>
<property name="SOAPAction" value="urn:getEmployeeXML" scope="transport" type="STRING"/>
<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
<send>
<endpoint>
<address uri="http://169.254.193.10:9763/services/StoredProcedureFarmacy" format="soap11"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="full"/>
<send/>
</outSequence>
<faultSequence>
<sequence key="{faultSEQ}"/>
</faultSequence>
</resource>
</api>
This is the response
{
"Employees": {
"Employe": [
{
"Id": 5,
"Description": "Office 2"
}
]
}
}

How to send to multiple endpoints in wso2esb

I am using wso2esb-4.8.1,
I wish to log the transaction details after response back to client.
For that I have written Proxy as well as sequence but wso2esb-4.8.1 is not supporting that with send mediator ,because I want t use load balance for every endpoint where as same logic is working in CallOUt mediator with URL option not with address endpoint .
proxy
<proxy xmlns="http://ws.apache.org/ns/synapse" name="Test_Proxy" transports="https http" startOnLoad="true" trace="disable">
<description/>
<target>
<inSequence onError="FaultSeq">
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true" scope="default" type="STRING"/>
<log>
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" name="ProxyInRequest"
expression="/soapenv:Envelope"/>
</log>
<xquery key="ProxyRequestTransformation">
<variable xmlns:ns="http://org.apache.synapse/xsd" name="Operation" expression="//Operation/text()" type="STRING"/>
<variable xmlns:ns="http://org.apache.synapse/xsd" name="ServiceNameSpace" expression="//ServiceNameSpace/text()" type="STRING"/>
<variable name="Payload" type="DOCUMENT_ELEMENT"/>
<variable xmlns:ns="http://org.apache.synapse/xsd" name="ServiceName" expression="//Service/text()" type="STRING"/>
</xquery>
<send>
<endpoint>
<address uri="http://localhost:8081/middleware/services/test1" format="soap11"/>
</endpoint>
</send>
</inSequence>
<outSequence onError="FaultSeq">
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true"/>
<property action="set" name="RESPONSE" scope="default" type="STRING" value="true"/>
<send/>
<sequence key="AuditSeq"/>
</outSequence>
</target>
<publishWSDL key="EaiEnvelope"/>
</proxy>
In above proxy i have used default send mediator after that trying to do audit in same flow ,My client is getting response back but details are not auditing even not getting any error.
My sequence
<sequence xmlns="http://ws.apache.org/ns/synapse" name="AuditSeq"> <property name="FORCE_ERROR_ON_SOAP_FAULT" value="true" scope="default" type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="RESULT_CODE" expression="get-property('ResultCode')" scope="default" type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="RESULT_MESSAGE" expression="get-property('ResultMessage')" scope="default" type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="REFERENCE_ID" expression="get-property('ReferenceID')" scope="default" type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="FAULT_DETAILS" expression="concat(get-property('ERROR_CODE'),get-property('ERROR_MESSAGE'))" scope="default" type="STRING"/>
<payloadFactory media-type="xml">
<format>
<open:processRequest xmlns:open="http://www.openuri.org/">
<aud:Auditor xmlns:aud="http://jhm.kkk.fff/Auditor">
<aud:Request>
<aud:Operation_Name>processRequest</aud:Operation_Name>
<aud:Auditor_InputData>
<aud:Result_Code>$1</aud:Result_Code>
<aud:Result_Message>$2</aud:Result_Message>
<aud:Reference_Id>$3</aud:Reference_Id>
</aud:Auditor_InputData>
</aud:Request>
</aud:Auditor>
</open:processRequest>
</format>
<args>
<arg evaluator="xml" expression="get-property('RESULT_CODE')"/>
<arg evaluator="xml" expression="get-property('RESULT_MESSAGE')"/>
<arg evaluator="xml" expression="get-property('REFERENCE_ID')"/>
</args>
</payloadFactory>
<header name="Action" scope="default" value="http://www.openuri.org/processRequest"/>
<send>
<endpoint>
<address uri="http://localhost:8081/middleware/services/AuditService" format="soap11"/>
</endpoint>
</send>
<log>
<property name="aftersend" value="message going out or not"/>
</log>
</sequence>
With above send mediator is not working .But after send my log is printing.
If i replace send mediator with CallOut URL option its working fine.
<callout serviceURL="http:///localhost:8081/middleware/services/AuditService">
<source type="envelope"/>
<target key="IsThisResponse"/>
</callout>
In above we are not able to use loadbalancing.For that I trying for send mediator.
Is any way to do this.
I thouhgt wso2esb-4.8.1 is become stable but again its having drawbacks.
Thanks in advance.
Please try by changing the send mediator in your proxy as mentioned here it may help you
<send receive="AuditSeq">
<endpoint>
<address uri="http://localhost:8081/middleware/services/test1" format="soap11"/>
</endpoint>
</send>

Can we get Class return Property in Proxy sequence

I written custom mediator and its working fine I am passing the values to my class mediator using insequence like this
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="tReadingMobile_5"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence onError="fault">
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true"/>
<property name="Reading"
expression="//Readings"
scope="default"
type="STRING"/>
<property name="actiondetailid"
expression="//actiondetailid/text()"
scope="default"
type="STRING"/>
<property name="actionid"
expression="//actionid/text()"
scope="default"
type="STRING"/>
<property name="userid"
expression="//userid/text()"
scope="default"
type="STRING"/>
<property name="assetid"
expression="//assetid/text()"
scope="default"
type="STRING"/>
<property name="partybranchid"
expression="//partybranchid/text()"
scope="default"
type="STRING"/>
<property name="activityid"
expression="//activityid/text()"
scope="default"
type="STRING"/>
<property name="clientid"
expression="//clientid/text()"
scope="default"
type="STRING"/>
<property name="ouid"
expression="//ouid/text()"
scope="default"
type="STRING"/>
<log level="custom">
<property name="fff" expression="get-property('Reading')"/>
<property name="ggggg" expression="get-property('actiondetailid')"/>
<property name="hhhh" expression="get-property('actionid')"/>
<property name="partybranchid" expression="get-property('partybranchid')"/>
</log>
<iterate continueParent="true"
id="Readings"
expression="//ReadingsLiteTaildto">
<target>
<sequence>
<property name="actiondetailid" expression="get-property('actiondetailid')"/>
<property name="parameterid" expression="//ParameterId/text()"/>
<property name="slno" expression="//SlNo/text()"/>
<property name="inputvalue" expression="//InputValue/text()"/>
<property name="inputtext" expression="//InputText/text()"/>
<property name="finalvalue" expression="//FinalValue/text()"/>
<payloadFactory>
<format>
<p:insert_treadings_operation xmlns:p="http://ws.wso2.org/dataservice">
<xs:actiondetailid xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:actiondetailid>
<xs:slno xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:slno>
<xs:parameterid xmlns:xs="http://ws.wso2.org/dataservice">$3</xs:parameterid>
<xs:inputvalue xmlns:xs="http://ws.wso2.org/dataservice">$4</xs:inputvalue>
<xs:inputtext xmlns:xs="http://ws.wso2.org/dataservice">$5</xs:inputtext>
<xs:finalvalue xmlns:xs="http://ws.wso2.org/dataservice">$6</xs:finalvalue>
</p:insert_treadings_operation>
</format>
<args>
<arg expression="get-property('actiondetailid')"/>
<arg expression="get-property('slno')"/>
<arg expression="get-property('parameterid')"/>
<arg expression="get-property('inputvalue')"/>
<arg expression="get-property('inputtext')"/>
<arg expression="get-property('finalvalue')"/>
</args>
</payloadFactory>
<send receive="tReadingsid_Seq">
<endpoint>
<address uri="http://localhost:9764/services/treadings_DataService/"
format="soap11"/>
</endpoint>
</send>
</sequence>
</target>
</iterate>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
<property xmlns:ns="http://org.apache.synapse/xsd"
name="Time"
expression="get-property('SYSTEM_TIME')"
scope="default"
type="STRING"/>
<property name="actiondetailid"
expression="get-property('actiondetailid')"
scope="default"
type="STRING"/>
<property name="OUT_ONLY" value="true"/>
<property name="dbconnectionurl"
value="jdbc:postgresql://$$$$$$$$$$/*****"/>
<property name="dbuser" value="##########"/>
<property name="dbpassword" value="*******"/>
<class name="in.youtility.esb.custommediators.ReadingAlertMediator"/>
<property name="Message"
expression="get-property('Message')"
scope="default"
type="STRING"/>
</inSequence>
<outSequence onError="fault"/>
</target>
</proxy>
The Message property is define inside the class
So i wish retrieve it from out side class means insequence
Is it possible in wso2esb or not if i get this property out of class then i will get scenario
Yes. It is possible. It will work as a normal property which you can refer at any place after you get the return value from class mediator.
You can get the property 'Message' as you have mentioned but before that you need to assign the result to the property 'Message'.
See the following sample of assign the result,
<class name="in.youtility.esb.custommediators.ReadingAlertMediator">
<property name="target" value="Message"/>
</class>