I use WSO2 ESB (4.8.1) and would like to know how to get the output as shown in the "Expected output" block.
Thanks in advance.
Proxy service definition:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="DATA_WS"
transports="https,http"
statistics="disable"
trace="enable"
startOnLoad="true">
<target>
<inSequence>
<switch xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
source="local-name(/*/*/*[1])">
<case regex="getSavProducts">
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:dat="http://ws.wso2.org/dataservice">
<soapenv:Header/>
<soapenv:Body>
<dat:getSavProducts/>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args/>
</payloadFactory>
<log level="custom">
<property name="operation" value="getSavProducts"/>
</log>
<send>
<endpoint>
<address uri="http://dssserver:9783/services/DATA_WS/getSavProducts"/>
</endpoint>
</send>
</case>
<default/>
</switch>
</inSequence>
<outSequence>
<iterate xmlns:m="http://ws.wso2.org/dataservice"
id="iter1"
expression="//m:Entries/m:Entry">
<target>
<sequence>
<log level="custom">
<property name="output111" expression="//m:PRODUCT_DESC/text()"/>
</log>
<send/>
</sequence>
</target>
</iterate>
</outSequence>
</target>
<publishWSDL key="gov:/IB/DATA_WS.wsdl"/>
<parameter name="useOriginalwsdl">true</parameter>
<parameter name="disableOperationValidation">true</parameter>
<description/>
</proxy>
this is the output i get when calling the service
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<Entry xmlns="http://ws.wso2.org/dataservice">
<PRODUCT_CODE>2</PRODUCT_CODE>
<SUB_PRODUCT_CODE>20</SUB_PRODUCT_CODE>
<PRODUCT_DESC>TEST SUB PRODUCT</PRODUCT_DESC>
<STATUS>A</STATUS>
<PRODUCT_CATEGORY>G</PRODUCT_CATEGORY>
<PRODUCT_NAME>General</PRODUCT_NAME>
<CUR_CODE>GBP</CUR_CODE>
<CHANNEL>USSD</CHANNEL>
</Entry>
</soapenv:Body>
</soapenv:Envelope>
log
TID: [0] [ESB] [2016-10-31 10:39:33,761] INFO {org.apache.synapse.mediators.builtin.LogMediator} - output111 = TEST SUB PRODUCT {org.apache.synapse.mediators.builtin.LogMediator}
TID: [0] [ESB] [2016-10-31 10:39:33,761] INFO {org.apache.synapse.mediators.builtin.LogMediator} - output111 = TEST SUB PRODUCT 2 {org.apache.synapse.mediators.builtin.LogMediator}
TID: [0] [ESB] [2016-10-31 10:39:33,768] INFO {org.apache.synapse.mediators.builtin.LogMediator} - output111 = TEST SUB PRODUCT 3 {org.apache.synapse.mediators.builtin.LogMediator}
Expected output
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:getSavProductsResponse SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="DATA_WS">
<return xsi:type="ns2:dbconncyberfin_DbtSavProdcutTab" xmlns:ns2="http://dbconncyberfin/DATA_WS.xsd">
<array xsi:type="ns3:Array" ns3:arrayType="ns2:dbconncyberfin_DbtSavProdcutUser[16]" xmlns:ns3="http://schemas.xmlsoap.org/soap/encoding/">
<item xsi:type="ns2:dbconncyberfin_DbtSavProdcutUser">
<channel xsi:type="xsd:string">USSD</channel>
<curCode xsi:type="xsd:string">EUR</curCode>
<productCategory xsi:type="xsd:string">G</productCategory>
<productCode xsi:type="xsd:string">2</productCode>
<productDesc xsi:type="xsd:string">TEST SUB PRODUCT</productDesc>
<productName xsi:type="xsd:string">General</productName>
<status xsi:type="xsd:string">A</status>
<subProductCode xsi:type="xsd:string">20</subProductCode>
</item>
<item xsi:type="ns2:dbconncyberfin_DbtSavProdcutUser">
<channel xsi:type="xsd:string">USSD</channel>
<curCode xsi:type="xsd:string">USD</curCode>
<productCategory xsi:type="xsd:string">G</productCategory>
<productCode xsi:type="xsd:string">2</productCode>
<productDesc xsi:type="xsd:string">TEST SUB PRODUCT 2</productDesc>
<productName xsi:type="xsd:string">General</productName>
<status xsi:type="xsd:string">A</status>
<subProductCode xsi:type="xsd:string">54</subProductCode>
</item>
<item xsi:type="ns2:dbconncyberfin_DbtSavProdcutUser">
<channel xsi:type="xsd:string">USSD</channel>
<curCode xsi:type="xsd:string">SLR</curCode>
<productCategory xsi:type="xsd:string">G</productCategory>
<productCode xsi:type="xsd:string">1</productCode>
<productDesc xsi:type="xsd:string">TEST SUB PRODUCT 3</productDesc>
<productName xsi:type="xsd:string">General</productName>
<status xsi:type="xsd:string">A</status>
<subProductCode xsi:type="xsd:string">00</subProductCode>
</item>
</array>
</return>
</ns1:getSavProductsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
solved it using xsl with xslt mediator.
item1.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
xmlns:m="http://ws.wso2.org/dataservice" version="2.0" exclude-result-prefixes="m fn"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ns1="DATA_WS">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<ns1:getSavProductsResponse>
<return xsi:type="ns2:dbconncyberfin_DbtSavProdcutTab" xmlns:ns2="http://dbconncyberfin/DATA_WS.xsd">
<array xsi:type="ns3:Array" ns3:arrayType="ns2:dbconncyberfin_DbtSavProdcutUser[16]" xmlns:ns3="http://schemas.xmlsoap.org/soap/encoding/">
<xsl:for-each select="//m:Entries/m:Entry">
<item xsi:type="ns2:dbconncyberfin_DbtSavProdcutUser">
<channel xsi:type="xsd:string"><xsl:value-of select="m:CHANNEL"/></channel>
<curCode xsi:type="xsd:string"><xsl:value-of select="m:CUR_CODE"/></curCode>
<productCategory xsi:type="xsd:string"><xsl:value-of select="m:PRODUCT_CATEGORY"/></productCategory>
<productCode xsi:type="xsd:string"><xsl:value-of select="m:PRODUCT_CODE"/></productCode>
<productDesc xsi:type="xsd:string"><xsl:value-of select="m:PRODUCT_DESC"/></productDesc>
<productName xsi:type="xsd:string"><xsl:value-of select="m:PRODUCT_NAME"/></productName>
<status xsi:type="xsd:string"><xsl:value-of select="m:STATUS"/></status>
<subProductCode xsi:type="xsd:string"><xsl:value-of select="m:SUB_PRODUCT_CODE"/></subProductCode>
</item>
</xsl:for-each>
</array>
</return>
</ns1:getSavProductsResponse>
</xsl:template>
outSequence
<outSequence>
<xslt key="gov:/xslt/item1.xsl"/>
<enrich>
<source type="body" clone="true"/>
<target type="property" property="original"/>
</enrich>
<payloadFactory media-type="xml">
<format>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body/>
</SOAP-ENV:Envelope>
</format>
<args/>
</payloadFactory>
<enrich>
<source type="property" clone="true" property="original"/>
<target type="body"/>
</enrich>
<send/>
</outSequence>
Related
Foreach is not working properly under AggregateMediator's scope in response flow
Input request :
[
{
"name" : "Home"
},
{
"name" : "Car"
},
{
"name" : "Mobile"
}
]
I am using iterate, to send each element of above array as a request to a pass-through service( In my actual project this is not pass through. For better understanding of issue I kept it like this ).
The responses of the pass through service are aggregated in one soap xml by AggregateMediator.
Below is response from AggregateMediator
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<Information>
<jsonObject>
<name>Mobile</name>
</jsonObject>
<jsonObject>
<name>Car</name>
</jsonObject>
<jsonObject>
<name>Home</name>
</jsonObject>
</Information>
</soapenv:Body>
</soapenv:Envelope>
Using foreach to modify each response depending on some parameters coming in response.
But the Foreach is not working properly under Aggregator scope in response flow . Its response is weird.
For-each response :
[2017-07-11 14:07:44,696] INFO - LogMediator msg4 = "Inside Foreach"
[2017-07-11 14:07:44,697] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:3e1fd827-12ab-413c-824d-c9daf7b6df7c, Direction: response, Envelope: <?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<jsonObject>
<name>Home</name>
</jsonObject>
</soapenv:Body>
</soapenv:Envelope>
[2017-07-11 14:07:44,697] INFO - LogMediator msg4 = "Inside Foreach"
[2017-07-11 14:07:44,697] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:3e1fd827-12ab-413c-824d-c9daf7b6df7c, Direction: response, Payload: {"name":"Home"}
[2017-07-11 14:07:44,697] INFO - LogMediator msg4 = "Inside Foreach"
[2017-07-11 14:07:44,698] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:3e1fd827-12ab-413c-824d-c9daf7b6df7c, Direction: response, Payload: {"name":"Home"}
--------------------------------------------------------------------------------
The second and third iterate of foreach should have been like below :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<jsonObject>
<name>Mobile</name>
</jsonObject>
</soapenv:Body>
</soapenv:Envelope>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<jsonObject>
<name>Car</name>
</jsonObject>
</soapenv:Body>
</soapenv:Envelope>
Instead of :
Payload: {"name":"Home"}
Payload: {"name":"Home"}
Please find below flow xml's.
forEachTest.xml :
<?xml version="1.0" encoding="UTF-8"?>
<api context="/foreschTest" name="foreachTest" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST GET" uri-template="/hi">
<inSequence>
<log level="full"/>
<log level="custom">
<property expression="//jsonArray" name="message"/>
</log>
<iterate expression="//jsonArray/jsonElement" id="1">
<target>
<sequence>
<log level="custom">
<property name="msg2" value=""Inside Foreach""/>
</log>
<log level="full"/>
<send>
<endpoint key="modifyAgrRespEP"/>
</send>
</sequence>
</target>
</iterate>
</inSequence>
<outSequence>
<property name="info" scope="default">
<Information xmlns=""/>
</property>
<aggregate id="1">
<completeCondition>
<messageCount max="-1" min="-1"/>
</completeCondition>
<onComplete enclosingElementProperty="info" expression="//jsonObject">
<log level="custom">
<property name="msg3" value=""Inside Aggr""/>
</log>
<log level="full"/>
<foreach expression="//Information/jsonObject">
<sequence>
<log level="custom">
<property name="msg4" value=""Inside Foreach""/>
</log>
<log level="full"/>
</sequence>
</foreach>
</onComplete>
</aggregate>
</outSequence>
<faultSequence/>
</resource>
</api>
modifyAgrRes (Passthrough flow) :
<?xml version="1.0" encoding="UTF-8"?>
<api context="/mod" name="modifyAgrRes" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST GET" uri-template="/aggr">
<inSequence>
<log level="custom">
<property name="message" value=""Inside Modify Service *************************""/>
</log>
<log level="custom">
<property expression="//jsonObject" name="location"/>
</log>
<respond/>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</resource>
</api>
I'm trying to use WS02 ESB 5.0 to call a web service every 15 seconds, so I have this task:
<?xml version="1.0" encoding="UTF-8"?>
<task class="org.apache.synapse.startup.tasks.MessageInjector"
group="synapse.simple.quartz" name="UpdateName" xmlns="http://ws.apache.org/ns/synapse">
<trigger cron="0/15 * * * * ?" />
<property name="message"
xmlns:task="http://www.wso2.org/products/wso2commons/tasks">
<def:login soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:def="http://DefaultNamespace" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<id xsi:type="xsd:string">usr</id>
<pw xsi:type="xsd:string">pwd</pw>
</def:login>
</property>
<property name="sequenceName" value="main"
xmlns:task="http://www.wso2.org/products/wso2commons/tasks" />
<property name="injectTo" value="sequence"
xmlns:task="http://www.wso2.org/products/wso2commons/tasks" />
</task>
And this sequence:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="main" xmlns="http://ws.apache.org/ns/synapse">
<in>
<send>
<endpoint>
<wsdl port="SakaiLogin" service="SakaiLoginService" trace="disable"
uri="http://myserver/sakai-axis/SakaiLogin.jws?wsdl" />
</endpoint>
</send>
</in>
<out>
<send />
</out>
<log level="full" />
</sequence>
Both from the examples shown in the documentation:
https://docs.wso2.com/display/ESB500/Adding+and+Scheduling+Tasks (See "Injecting the message to a named sequence or proxy service").
https://docs.wso2.com/display/ESB500/Sample+56:+Using+a+WSDL+Endpoint+as+the+Target+Endpoint (See "Building the sample").
However, I'm getting this error once I start the Carbon WSO2 ESB server:
[2017-01-27 17:03:45,005] ERROR - InMediator Runtime error occurred while mediating the message
java.lang.NullPointerException
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.isTransportSwitching(Axis2SynapseEnvironment.java:783)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:545)
at org.apache.synapse.endpoints.AbstractEndpoint.send(AbstractEndpoint.java:382)
at org.apache.synapse.endpoints.WSDLEndpoint.send(WSDLEndpoint.java:75)
at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:121)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:59)
at org.apache.synapse.mediators.filters.InMediator.mediate(InMediator.java:74)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:59)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.apache.synapse.mediators.MediatorWorker.run(MediatorWorker.java:80)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
[2017-01-27 17:03:45,023] INFO - LogMediator To: ,
MessageID: urn:uuid:097fb69e-6461-428e-ac85-93cfde65d02e,
Direction: request,
MESSAGE = Executing default 'fault' sequence,
ERROR_CODE = 0,
ERROR_MESSAGE = Runtime error occurred while mediating the message, Envelope:
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<def:login xmlns:def="http://DefaultNamespace" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<id xmlns="http://ws.apache.org/ns/synapse" xsi:type="xsd:string">usr</id>
<pw xmlns="http://ws.apache.org/ns/synapse" xsi:type="xsd:string">pwd</pw>
</def:login></soapenv:Body></soapenv:Envelope>
Can anybody give me a clue of what is going on?
Much appreciated!
In the wsdl endpoint the uri value must be the WSDL address, not the service endpoint:
WSDL URI The URI of the WSDL. Click Test to test the URI.
So, the WSDL endpoint inside the send mediator extracts the service endpoint from the WSDL document using the service and port name to find it inside the wsdl document.
UPDATE 1:
My task config xml:
<?xml version="1.0" encoding="UTF-8"?>
<task xmlns="http://ws.apache.org/ns/synapse"
name="UpdateName"
class="org.apache.synapse.startup.tasks.MessageInjector"
group="synapse.simple.quartz">
<trigger cron="0/15 * * * * ?"/>
<property name="proxyName" value="testTask"/>
<property name="message">
<moc:QRY_SELECT_SRH_EMPLEADO xmlns:moc="http://www.example.org/mockWS/">
<INT_ID>gero et</INT_ID>
</moc:QRY_SELECT_SRH_EMPLEADO>
</property>
<property name="soapAction"
value="http://www.example.org/mockWS/QRY_SELECT_SRH_EMPLEADO"/>
<property name="injectTo" value="proxy"/>
</task>
My sequence named main1:
<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="main1">
<in>
<header name="Action" scope="default" value="http://www.example.org/mockWS/QRY_SELECT_SRH_EMPLEADO"/>
<send>
<endpoint>
<wsdl service="mockWS"
port="mockWSSOAP"
uri="http://localhost:8088/mockmockWSSOAP?wsdl"/>
</endpoint>
</send>
</in>
<out>
<log level="full"/>
<drop/>
</out>
</sequence>
And finally I created a proxy with the same logic because a issue with the drop mediator inside a sequence:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="testTask"
transports="https http"
startOnLoad="true">
<target>
<inSequence>
<header name="Action" scope="default" value="http://www.example.org/mockWS/QRY_SELECT_SRH_EMPLEADO"/>
<send>
<endpoint>
<wsdl service="mockWS"
port="mockWSSOAP"
uri="http://localhost:8088/mockmockWSSOAP?wsdl"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="full"/>
<drop/>
</outSequence>
<faultSequence/>
</target>
</proxy>
I am using WSO2 ESB to send a JMS message (XML payload) to an endpoint and then to read a return JMS message (on another queue) from the same endpoint (which also sends an XML payload). The problem I am facing is that the return JMS message from the endpoint, even though it is an XML payload, comes in as a text message.
Here is what I see in WSO2 for the JMS message (with XML payload) sent back by the endpoint:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<axis2ns2:text xmlns:axis2ns2="http://ws.apache.org/commons/ns/payload">
<?xml version="1.0" encoding="UTF-8"?>
<Sys1Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Sys1-ack-nack.xsd">
<security>
<statusInfo>
<ARMStatus>ARM_ACK</ARMStatus>
<Sys1Status>Sys1_ACK</Sys1Status>
<FinalStatus>ACK</FinalStatus>
</statusInfo>
<upstreamIdentifier>
<tradeId>459609</tradeId>
<messageId>12345678</messageId>
<assetId>6M2</assetId>
<issueDescription>IRS RTP 3.12 19MAY11 JP</issueDescription>
<productType>SWAPTION</productType>
</upstreamIdentifier>
</security>
</Sys1Response>
</axis2ns2:text>
</soapenv:Body>
</soapenv:Envelope>
This is the WSO2 proxy definition.
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://ws.apache.org/ns/synapse">
<registry provider="org.wso2.carbon.mediation.registry.ESBRegistry">
<parameter name="localRegistry">/</parameter>
<parameter name="cachableDuration">15000</parameter>
</registry>
<proxy name="ToWSO2"
transports="jms"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="transport.jms.ContentTypeProperty"
value="Content-Type"
scope="axis2"/>
<log level="full"/>
<call>
<endpoint>
<address uri="jms:/ToSys1?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616&transport.jms.DestinationType=queue&transport.jms.ReplyDestinationType=queue&transport.jms.ReplyDestination=FromSys1&transport.jms.ContentType=application/xml"/>
</endpoint>
</call>
<log level="full"/>
</inSequence>
<outSequence>
<log level="full"/>
<drop/>
</outSequence>
</target>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>application/xml</default>
</rules>
</parameter>
<parameter name="transport.jms.Destination">ToWSO2</parameter>
</proxy>
<sequence name="fault">
<log level="full">
<property name="MESSAGE" value="Executing default 'fault' sequence"/>
<property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
<property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
</log>
<drop/>
</sequence>
<sequence name="main">
<in>
<log level="full"/>
<filter source="get-property('To')" regex="http://localhost:9000.*">
<send/>
</filter>
</in>
<out>
<send/>
</out>
<description>The main sequence for the message mediation</description>
</sequence>
</definitions>
Would appreciate help in resolving this. Many thanks in advance!
I am using wso2esb4.8.0
I wish to transform the message using wso2esb .Actaulle need to add Complex Element to Payload
How would i achive this.
my Client request is
<?xml version="1.0" encoding="UTF-8"?>
But my Adapter endpoint will allow the request in this format.If it is for one operation i may follow payload mediator to make my request But those are bumch of requests
so Endpoint allowing request is
Just extract the Operation_Name and adding it as Complex Element But I am unable to do it I am trying in Proxy like this
Proxy is
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="SamplePOC7"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property xmlns:open="http://www.openuri.org/"
xmlns:ns="http://org.apache.synapse/xsd"
xmlns:env="http://eai.mmn.mm/Envelope"
xmlns:poin="http://eai.mm.mm/gg"
name="Operation_Name"
expression="//poin:Operation_Name/text()"
scope="default"
type="STRING"/>
<property xmlns:open="http://www.openuri.org/"
xmlns:ns="http://org.apache.synapse/xsd"
xmlns:env="http://eai.mmn.xxxx/Envelope"
name="AddElement"
expression="concat('open:',get-property('Operation_Name'))"
scope="default"
type="STRING"/>
<enrich>
<source xmlns:env="http://eai.mmn.mm/Envelope"
clone="true"
xpath="//env:Payload/*"/>
<target xmlns:poin="http://eai.mm.XXX/gg"
xpath="concat('open:',//poin:Operation_Name/text())"/>
</enrich>
<log level="full">
<property name="Message" expression="get-property('AddElement')"/>
</log>
</inSequence>
<outSequence/>
</target>
<description/>
</proxy>
But its giving errors like the below my error log is
[2014-05-15 10:53:48,167] INFO - ProxyService Successfully created the Axis2 se
rvice for Proxy service : SamplePOC7
[2014-05-15 10:53:53,089] ERROR - EnrichMediator Invalid Target object to be enr
ich.
[2014-05-15 10:54:19,160] INFO - ProxyService Building Axis service for Proxy s
With which mediator i can extract this request as per my desire way please if you know paste configuration or else provide any example
Thanks in advance
You can use XSLT mediator or JavaScript
A sample proxy with javascript doing what you want :
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="TestSOF"
transports="http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
<property xmlns:open="http://www.openuri.org/"
xmlns:ns="http://org.apache.synapse/xsd"
xmlns:poin="http://eai.mtn.iran/PointOfSales"
name="Operation_Name"
expression="//poin:Operation_Name/text()"
scope="default"
type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd"
xmlns:poin="http://eai.mtn.iran/PointOfSales"
name="PointOfSales"
expression="//poin:PointOfSales"
scope="default"
type="STRING"/>
<script language="js"><![CDATA[
mc.setPayloadXML(<open:{mc.getProperty("Operation_Name")} xmlns:open="http://www.openuri.org/">
{new XML(mc.getProperty("PointOfSales"))}
</open:{mc.getProperty("Operation_Name")}>);
]]></script>
<log level="full"/>
</inSequence>
</target>
</proxy>
A sample using XSLT :
<?xml version="1.0" encoding="UTF-8"?>
<localEntry xmlns="http://ws.apache.org/ns/synapse" key="SOFXSL">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:open="http://openuri.org/"
xmlns:env="http://eai.mtnn.iran/Envelope"
xmlns:poin="http://eai.mtn.iran/PointOfSales"
version="2.0">
<xsl:output method="xml" encoding="utf-8" indent="yes" omit-xml-declaration="no"/>
<xsl:param name="operationname"/>
<xsl:template match="/">
<xsl:element name="open:{$operationname}">
<xsl:apply-templates select="//poin:PointOfSales"/>
</xsl:element>
</xsl:template>
<xsl:template match="#*|*|comment()">
<xsl:copy>
<xsl:apply-templates select="#*|*|text()|comment()|processing-instruction()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
<description/>
</localEntry>
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="TestSOF"
transports="http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
<property xmlns:open="http://www.openuri.org/"
xmlns:ns="http://org.apache.synapse/xsd"
xmlns:poin="http://eai.mtn.iran/PointOfSales"
name="Operation_Name"
expression="//poin:Operation_Name/text()"
scope="default"
type="STRING"/>
<xslt key="SOFXSL">
<property name="operationname" expression="get-property('Operation_Name')"/>
</xslt>
<log level="full"/>
</inSequence>
</target>
</proxy>
I use WSO2 ESB 4.5.1 on Windows.
My problem is that the temp folder WSO2_HOME/tmp is growing up and never cleaned.
I found out that the problem comes from the xslt mediator, everytime it transform a big xml file (~15kb) a new temp file is created.
Does anyone have an idea why these tmp files are not cleaned up?
Proxy:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="input" transports="vfs" startOnLoad="true" trace="disable">
<parameter name="transport.PollInterval">5</parameter>
<parameter name="transport.vfs.FileURI">vfs:file://C:/WSO2/Test/From</parameter>
<parameter name="transport.vfs.FileNamePattern">.*[.].*</parameter>
<parameter name="transport.vfs.ContentType">application/xml</parameter>
<target faultSequence="errorSequence">
<inSequence>
<log level="full"/>
<property name="ClientApiNonBlocking" scope="axis2" action="remove"/>
<property name="OUT_ONLY" value="true"/>
<xslt key="avintis_xml_indent"/>
<property name="transport.vfs.ReplyFileName" expression="fn:concat('out_', $trp:FILE_NAME, '.xml')" scope="transport"/>
<send>
<endpoint>
<address uri="vfs:file://C:/WSO2/Test/To"/>
</endpoint>
</send>
</inSequence>
</target>
</proxy>
XSLT:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:avintis="http://www.avintis.com/esb"
xmlns:urn="urn:hl7-org:v2xml" version="2.0"
xmlns:payload="http://ws.apache.org/commons/ns/payload">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="*|text()|#*">
<xsl:copy>
<xsl:apply-templates select="*|text()|#*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
inputfile:
any xml file bigger than ~15kb
Seems temp files do not get cleaned up by the HouseKeeping Task. To clean them using the housekeeping task you can configure it in the Carbon.xml as shown below.
<WorkDirectory>${carbon.home}/tmp/work</WorkDirectory>
<HouseKeeping>
<AutoStart>true</AutoStart>
<Interval>10</Interval>
<MaxTempFileLifetime>30</MaxTempFileLifetime>
</HouseKeeping>