Set Custom Payload in wso2 ESB or AM? - wso2

I have a rest API in ESB server.I need to set payload as follows
<fields>Name</fields>
<query>
<term>
<NUM>100</NUM>
</term>
</query>
any suggestion ?

you could use the payloadfactory mediator in ESB 4.8.1, take this xml as an example. you need to do some changes :-) but it´s an start:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="JsonToXMLProxy"
transports="https http local"
startOnLoad="true"
trace="disable">
<description/>
<target>
<endpoint>
<address uri="http://www.w3schools.com/webservices/tempconvert.asmx" format="soap11"/>
</endpoint>
<inSequence>
<log>
<property name="TEMPERATURA_ENTRADA" expression="json-eval($.celsius)"/>
</log>
<payloadFactory media-type="xml">
<format>
<web:CelsiusToFahrenheit xmlns:web="http://www.w3schools.com/webservices/">
<web:Celsius>$1</web:Celsius>
</web:CelsiusToFahrenheit>
</format>
<args>
<arg evaluator="json" expression="$.celsius"/>
</args>
</payloadFactory>
<header name="Action"
value="http://www.w3schools.com/webservices/CelsiusToFahrenheit"/>
</inSequence>
<outSequence>
<log>
<property xmlns:p="http://www.w3schools.com/webservices/"
name="TEMPERATURA_SALIDA"
expression="//p:CelsiusToFahrenheitResponse/p:CelsiusToFahrenheitResult"/>
</log>
<payloadFactory media-type="json">
<format>
"Temperatura" : {
"EnFahrenheit" : $1
}
</format>
<args>
<arg xmlns:p="http://www.w3schools.com/webservices/"
evaluator="xml"
expression="//p:CelsiusToFahrenheitResponse/p:CelsiusToFahrenheitResult"/>
</args>
</payloadFactory>
<property name="messageType" value="application/json" scope="axis2"/>
<send/>
</outSequence>
</target>
</proxy>

Try payload/enrich mediators ..

Related

I got a problem in rest api project in wso2 integration studio

I Have this xml:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/testapi" name="testapi" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" url-mapping="/testapi">
<inSequence>
<property expression="get-property('query.param.qp')" name="qp1" scope="default" type="STRING"/>
<property expression="$ctx:query.param.qp" name="qp2" scope="default" type="STRING"/>
<property expression="$url:qp" name="qp3" scope="default" type="STRING"/>
<payloadFactory media-type="json">
<format> {"Method1":"$1",
"Method2":"$2",
"Method3":"$3"}</format>
<args>
<arg evaluator="xml" expression="get-property('qp1')"/>
<arg evaluator="xml" expression="get-property('qp2')"/>
<arg evaluator="xml" expression="get-property('qp3')"/>
</args>
</payloadFactory>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
when validating the code in the integration studio these problems appears:
Element 'format' cannot have character [children], because the type's content type is element-only. testapi.xml /test1/test1Configs/src/main/synapse-config/api line 9 XML Problem
The content of element 'faultSequence' is not complete. One of '{"http://ws.apache.org/ns/synapse":call, "http://ws.apache.org/ns/synapse":call-template, "http://ws.apache.org/ns/synapse":drop, "http://ws.apache.org/ns/synapse":log, "http://ws.apache.org/ns/synapse":loopback, "http://ws.apache.org/ns/synapse":property, "http://ws.apache.org/ns/synapse":propertyGroup, "http://ws.apache.org/ns/synapse":respond, "http://ws.apache.org/ns/synapse":send, "http://ws.apache.org/ns/synapse":sequence, "http://ws.apache.org/ns/synapse":store, "http://ws.apache.org/ns/synapse":conditionalRouter, "http://ws.apache.org/ns/synapse":filter, "http://ws.apache.org/ns/synapse":switch, "http://ws.apache.org/ns/synapse":validate, "http://ws.apache.org/ns/synapse":bean, "http://ws.apache.org/ns/synapse":class, "http://ws.apache.org/ns/synapse":pojoCommand, "http://ws.apache.org/ns/synapse":ejb, "http://ws.apache.org/ns/synapse":script, "http://ws.apache.org/ns/synapse":spring, "http://ws.apache.org/ns/synapse":enrich, "http://ws.apache.org/ns/synapse":makefault, "http://ws.apache.org/ns/synapse":header, "http://ws.apache.org/ns/synapse":payloadFactory, "http://ws.apache.org/ns/synapse":jsontransform, "http://ws.apache.org/ns/synapse":smooks, "http://ws.apache.org/ns/synapse":rewrite, "http://ws.apache.org/ns/synapse":xquery, "http://ws.apache.org/ns/synapse":xslt, "http://ws.apache.org/ns/synapse":datamapper, "http://ws.apache.org/ns/synapse":fastXSLT, "http://ws.apache.org/ns/synapse":cache, "http://ws.apache.org/ns/synapse":dblookup, "http://ws.apache.org/ns/synapse":dbreport, "http://ws.apache.org/ns/synapse":enqueue, "http://ws.apache.org/ns/synapse":event, "http://ws.apache.org/ns/synapse":throttle, "http://ws.apache.org/ns/synapse":transaction, "http://ws.apache.org/ns/synapse":aggregate, "http://ws.apache.org/ns/synapse":callout, "http://ws.apache.org/ns/synapse":clone, "http://ws.apache.org/ns/synapse":iterate, "http://ws.apache.org/ns/synapse":foreach, "http://ws.apache.org/ns/synapse":entitlementService, "http://ws.apache.org/ns/synapse":oauthService, "http://ws.apache.org/ns/synapse":builder, "http://ws.apache.org/ns/synapse":rule, "http://ws.apache.org/ns/synapse":bam, "http://ws.apache.org/ns/synapse":publishEvent, "http://ws.apache.org/ns/synapse":NTLM}' is expected. testapi.xml /test1/test1Configs/src/main/synapse-config/api line 3 XML Problem
The content of element 'outSequence' is not complete. One of '{"http://ws.apache.org/ns/synapse":call, "http://ws.apache.org/ns/synapse":call-template, "http://ws.apache.org/ns/synapse":drop, "http://ws.apache.org/ns/synapse":log, "http://ws.apache.org/ns/synapse":loopback, "http://ws.apache.org/ns/synapse":property, "http://ws.apache.org/ns/synapse":propertyGroup, "http://ws.apache.org/ns/synapse":respond, "http://ws.apache.org/ns/synapse":send, "http://ws.apache.org/ns/synapse":sequence, "http://ws.apache.org/ns/synapse":store, "http://ws.apache.org/ns/synapse":conditionalRouter, "http://ws.apache.org/ns/synapse":filter, "http://ws.apache.org/ns/synapse":switch, "http://ws.apache.org/ns/synapse":validate, "http://ws.apache.org/ns/synapse":bean, "http://ws.apache.org/ns/synapse":class, "http://ws.apache.org/ns/synapse":pojoCommand, "http://ws.apache.org/ns/synapse":ejb, "http://ws.apache.org/ns/synapse":script, "http://ws.apache.org/ns/synapse":spring, "http://ws.apache.org/ns/synapse":enrich, "http://ws.apache.org/ns/synapse":makefault, "http://ws.apache.org/ns/synapse":header, "http://ws.apache.org/ns/synapse":payloadFactory, "http://ws.apache.org/ns/synapse":jsontransform, "http://ws.apache.org/ns/synapse":smooks, "http://ws.apache.org/ns/synapse":rewrite, "http://ws.apache.org/ns/synapse":xquery, "http://ws.apache.org/ns/synapse":xslt, "http://ws.apache.org/ns/synapse":datamapper, "http://ws.apache.org/ns/synapse":fastXSLT, "http://ws.apache.org/ns/synapse":cache, "http://ws.apache.org/ns/synapse":dblookup, "http://ws.apache.org/ns/synapse":dbreport, "http://ws.apache.org/ns/synapse":enqueue, "http://ws.apache.org/ns/synapse":event, "http://ws.apache.org/ns/synapse":throttle, "http://ws.apache.org/ns/synapse":transaction, "http://ws.apache.org/ns/synapse":aggregate, "http://ws.apache.org/ns/synapse":callout, "http://ws.apache.org/ns/synapse":clone, "http://ws.apache.org/ns/synapse":iterate, "http://ws.apache.org/ns/synapse":foreach, "http://ws.apache.org/ns/synapse":entitlementService, "http://ws.apache.org/ns/synapse":oauthService, "http://ws.apache.org/ns/synapse":builder, "http://ws.apache.org/ns/synapse":rule, "http://ws.apache.org/ns/synapse":bam, "http://ws.apache.org/ns/synapse":publishEvent, "http://ws.apache.org/ns/synapse":NTLM}' is expected. testapi.xml /test1/test1Configs/src/main/synapse-config/api line 3 XML Problem
Cannot find the declaration of element 'project'. pom.xml /test1/test1CompositeExporter line 3 XML Problem
Referenced file contains errors (jar:file:/D:/WSO2-Integration-Studio-8.1.0-win32-x86_64/IntegrationStudio/plugins/org.wso2.integrationstudio.gmf.esb.diagram_8.1.0.202211111317.jar!/resources/schema/endpoint.xsd). For more information, right click on the message in the Problems View and select "Show Details..." testapi.xml /test1/test1Configs/src/main/synapse-config/api line 1 XML Problem
I try to build rest api with wso2 integration studio
You have to delete those Caracters "&#xd" from your JSON Payload as below :
<?xml version="1.0" encoding="UTF-8"?>
<api context="/testapi" name="testapi" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" url-mapping="/testapi">
<inSequence>
<property expression="get-property('query.param.qp')" name="qp1" scope="default" type="STRING"/>
<property expression="$ctx:query.param.qp" name="qp2" scope="default" type="STRING"/>
<property expression="$url:qp" name="qp3" scope="default" type="STRING"/>
<payloadFactory media-type="json">
<format> {"Method1":"$1",
"Method2":"$2",
"Method3":"$3"}</format>
<args>
<arg evaluator="xml" expression="get-property('qp1')"/>
<arg evaluator="xml" expression="get-property('qp2')"/>
<arg evaluator="xml" expression="get-property('qp3')"/>
</args>
</payloadFactory>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>

WSO2 Ei 6.1 email received as attachment

I have a service which send the email from WSo2 server. But i am getting the message content as attachment and not in body of the email.
You can define the message content for the email body using payload factory mediator as below.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="mailtest"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="http,https">
<target>
<inSequence>
<send>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<payloadFactory media-type="xml">
<format>
<test xmlns="">$1</test>
</format>
<args>
<arg xmlns:ax21="http://services.samples/xsd"
xmlns:ns="http://services.samples"
evaluator="xml"
expression="//ns:getQuoteResponse/ns:return/ax21:name"/>
</args>
</payloadFactory>
<property name="Subject" scope="transport" value="Sample Mail"/>
<property name="OUT_ONLY" scope="default" type="STRING" value="true"/>
<property name="messageType"
scope="axis2"
type="STRING"
value="text/plain"/>
<property name="OUT_ONLY" value="true"/>
<send>
<endpoint>
<address uri="mailto:yourmail#gmail.com"/>
</endpoint>
</send>
</outSequence>
</target>
<description/>
</proxy>
If you want to define a message body with the email attachment, use "transport.mail.bodyWhenAttached" property.

Iterate Mediator sends duplicate payload almost always

We are trying out a scenario where we want to iterate over a list of nodes and make a POST call to some service with each individual request payload. We are seeing the iterate mediator actually sends two elements in that call and
that causes issues on the API end.
I have a mock service deployed locally that returns response say :
<result>
<row>
<product_id>8351</product_id>
<event_key>17708</event_key>
<event_code>AEONBM</event_code>
<show_title>Some Show</show_title>
<venue_name>Eugene ONeill Theatre</venue_name>
<area>ORCHC</area>
<row>C</row>
<seat_num>103</seat_num>
<seat_increment>1</seat_increment>
<marketing_code>PREMIUM</marketing_code>
<Cost>352.0000</Cost>
</row>
<row>
<product_id>8351</product_id>
<event_key>17708</event_key>
<event_code>AEONBM</event_code>
<show_title>Some Show</show_title>
<venue_name>Eugene ONeill Theatre</venue_name>
<area>ORCHC</area>
<row>C</row>
<seat_num>104</seat_num>
<seat_increment>1</seat_increment>
<marketing_code>PREMIUM</marketing_code>
<Cost>352.0000</Cost>
</row
</result>
Here is how my proxy service looks like:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="CreateListingFromGetLocation"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full">
<property name="text" value="Triggering getLocation API call.."/>
</log>
<send receive="createListingsFromGetLocationResponseSequence">
<endpoint>
<http method="get" uri-template="http://localhost:8989/GetLocation/"/>
</endpoint>
</send>
<property name="OUT_ONLY" value="true"/>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</target>
<description/>
</proxy>
Here is my receiving sequence that is using the iterate mediator:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="createListingsFromGetLocationResponseSequence">
<iterate xmlns:tem="http://tempuri.org" xmlns:ns="http://org.apache.synapse/xsd" expression="//result/row">
<target>
<sequence>
<log level="full">
<property name="LocationRow" value="Row element from GetLocationResponse"></property>
</log>
<payloadFactory media-type="xml">
<format>
<listing xmlns="">
<eventId>$1</eventId>
<eventDescription>$2</eventDescription>
<pricePerTicket>
<amount>$3</amount>
<currency>USD</currency>
</pricePerTicket>
<quantity>$4</quantity>
<section>$5</section>
<rows>$6</rows>
<seats>$7</seats>
<splitOption>NONE</splitOption>
</listing>
</format>
<args>
<arg expression="//event_key" evaluator="xml"></arg>
<arg expression="//show_title" evaluator="xml"></arg>
<arg expression="//Cost" evaluator="xml"></arg>
<arg expression="//seat_increment" evaluator="xml"></arg>
<arg expression="//area" evaluator="xml"></arg>
<arg expression="//row/row" evaluator="xml"></arg>
<arg expression="//seat_num" evaluator="xml"></arg>
</args>
</payloadFactory>
<log level="full">
<property name="ListingRequest" value="Listing request xml"></property>
</log>
<property name="Content-Type" value="application/xml" scope="transport" type="STRING"></property>
<property name="messageType" value="application/xml" scope="transport" type="STRING"></property>
<property name="TARGET_HOST" value="srwd30" scope="transport" type="STRING"></property>
<property name="HTTP_METHOD" value="POST" scope="transport" type="STRING"></property>
<send>
<endpoint>
<http format="pox" method="post" uri-template="http://www.srwd30.com/listings/v1/"></http>
</endpoint>
</send>
</sequence>
</target>
</iterate>
</sequence>
Firstly, I see that it is iterating over each xml node properly, here are some logs indicating that:
[2014-04-22 13:29:42,020] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:3bc14a33-3a7a-478e-bdbf-720f1ec855a5, Direction: response, LocationRow = Row element from GetLocationResponse, Envelope: <?xml version="1.0" encoding="utf-8
"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><row>
<product_id>8351</product_id>
<event_key>17708</event_key>
<event_code>AEONBM</event_code>
<show_title>Some Show</show_title>
<venue_name>Eugene ONeill Theatre</venue_name>
<area>ORCHC</area>
<row>D</row>
<seat_num>103</seat_num>
<seat_increment>1</seat_increment>
<marketing_code>PREMIUM</marketing_code>
<Cost>352.0000</Cost>
</row></soapenv:Body></soapenv:Envelope>
[2014-04-22 13:29:42,021] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:0e04ac15-a0bf-41a3-a7d7-80a1401d3efc, Direction: response, ListingRequest = Listing request xml, Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:En
velope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><listing><eventId>17708</eventId><eventDescription>Some Show</eventDescription><pricePerTicket><amount>352.0000</amount><currency>USD</currency></pricePerTicket><quantity>1</quantity><section>ORCHC</section><rows
>C</rows><seats>103</seats><splitOption>NONE</splitOption></listing></soapenv:Body></soapenv:Envelope>
But on my API I see that we are receiving duplicate or two root nodes:
Content-Type: application/xml
Headers: {cache-control=[no-cache], connection=[Keep-Alive],
content-type=[application/xml], host=[www.srwd30.com], http_method=[POST], messagetype=[application/xml], target_host=[srwd30], transfer-encoding=
[chunked], user-agent=[Synapse-PT-HttpComponents-NIO]}
Payload: <listing><eventId>17708</eventId><eventDescription>Some Show</eventDescription><pricePerTicket><amount>352.0000</amount><currency>USD</currenc
y></pricePerTicket><quantity>1</quantity><section>ORCHC</section><rows>C</rows><seats>103</seats><splitOption>NONE</splitOption></listing><listing><eventId>1770
8</eventId><eventDescription>Some Show</eventDescription><pricePerTicket><amount>352.0000</amount><currency>USD</currency></pricePerTicket><quantity>1<
/quantity><section>ORCHC</section><rows>D</rows><seats>104</seats><splitOption>NONE</splitOption></listing>
--------------------------------------
2014-04-22 19:01:51,468 [e14f#fbf/http://www.srwd30.com/listings/v1/] priority=WARN app_name=shared-stubhubjobs thread=http-0.0.0.0-
8080-8 location=AbstractJAXBProvider line=112 javax.xml.bind.UnmarshalException
- with linked exception:
[com.ctc.wstx.exc.WstxParsingException: Illegal to have multiple roots (start tag in epilog?).
at [row,col {unknown-source}]: [1,291]]
From the looks of it, iterator is sending two elements when I make that send call. Am i missing something or doing something wrong? How can make each call independent from other?
I got the issue resolved by adding a Action header using urn:test value for that header. I realized that this was causing that duplicate requests to be sent and sometimes only one request being sent even if the iterator has about 10 records.
<proxy name="PushInventory"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<log level="full">
<property name="STATUS"
value="+++++++++++++++++ Inside PushInventory Proxy Service ++++++++++++++++++"/>
</log>
<iterate xmlns:tem="http://tempuri.org"
xmlns:ns="http://org.apache.synapse/xsd"
id="pushInventoryIterator"
expression="//result/row"
sequential="true">
<target>
<sequence>
<payloadFactory media-type="xml">
<format>
<listing xmlns="">
<eventId>$1</eventId>
<eventDescription>$2</eventDescription>
<pricePerTicket>
<amount>$3</amount>
<currency>USD</currency>
</pricePerTicket>
<quantity>$4</quantity>
<section>$5</section>
<rows>$6</rows>
<seats>$7</seats>
<splitOption>NONE</splitOption>
</listing>
</format>
<args>
<arg evaluator="xml" expression="//event_key"/>
<arg evaluator="xml" expression="//show_title"/>
<arg evaluator="xml" expression="//Cost"/>
<arg evaluator="xml" expression="//seat_increment"/>
<arg evaluator="xml" expression="//area"/>
<arg evaluator="xml" expression="//row_desc"/>
<arg evaluator="xml" expression="//seat_num"/>
</args>
</payloadFactory>
<log level="full">
<property name="STATUS"
value="++++++++++++ Invoking Listing EndPoint ++++++++++++++"/>
</log>
<property name="Authorization"
value="Basic dafdsfadsfdsafdsfdsafdsafsdfadsf"
scope="transport"
type="STRING"/>
<property name="Content-Type"
value="application/xml"
scope="transport"
type="STRING"/>
<property name="messageType"
value="application/xml"
scope="axis2"
type="STRING"/>
<property name="HTTP_METHOD" value="POST" scope="transport" type="STRING"/>
<header name="Action" scope="default" value="urn:test"/>
<send>
<endpoint key="ListingEndPoint"/>
</send>
</sequence>
</target>
</iterate>
</inSequence>
<outSequence>
<log level="full">
<property name="STATUS"
value="+++++++++++++++++ Inside OutSequence of PushInventory ++++++++++++++++++"/>
</log>
<aggregate>
<completeCondition>
<messageCount min="10" max="10"/>
</completeCondition>
<onComplete xmlns:ns2="com.blah.blah" expression="//listing">
<log level="full" separator=",">
<property name="STATUS"
value="+++++++++++++++++ Aggregating responses back ++++++++++++++++++"/>
</log>
<enrich>
<source type="envelope" clone="true"/>
<target type="body"/>
</enrich>
<send/>
</onComplete>
</aggregate>
</outSequence>
</target>
</proxy>
You put your log before the iterator mediator and see what you're receiving from the endpoint. It may contain duplicate entries. Then within iterate you have another log mediator. Check for records are right.

how to make a fault message and send it to a jms provider

I'am evaluating WSO2 esb and try this simple use case :
jms -> (esb) -> WebService (HelloService on WSO2 Application Server)
Send ws response to jms queue (end point EPQ_ESB_OUT)
Send fault to jms queue (end point EPQ_ESB_ERR)
When I stop WSO2 Application Server, the fault sequence is called and a message is sent to EPQ_ESB_ERR but the message is always empty...
I've tried to use makefault and buildfactory mediators but it fails in both case (empty message in both case).
My Proxy :
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="Test04Proxy02" transports="jms" startOnLoad="true" trace="enable">
<target>
<endpoint key="EPW_HelloService"/>
<inSequence>
<log>
<property name="STEP" value="==== INseq"/>
</log>
</inSequence>
<outSequence>
<property name="OUT_ONLY" value="true"/>
<log>
<property name="STEP" value="==== OUTseq"/>
</log>
<send>
<endpoint key="EPQ_ESB_OUT"/>
</send>
</outSequence>
<faultSequence>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<log level="full">
<property name="STEP" value="==== FAULTseq"/>
<property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
<property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
<property name="ERROR_DETAIL" expression="get-property('ERROR_DETAIL')"/>
</log>
<payloadFactory>
<format>
<ns:text xmlns:ns="http://myns">$1</ns:text>
</format>
<args>
<arg xmlns:ns="http://myns"
evaluator="xml"
expression="get-property('ERROR_MESSAGE')"/>
</args>
</payloadFactory>
<send>
<endpoint key="EPQ_ESB_ERR"/>
</send>
</faultSequence>
</target>
</proxy>
Any help would be appreciate. Thanks.
Just a guess:
Maybe you are having some issues with namesspaces. WSO seems to use the ns namespace itself extensively, so I would try using a different namespace in your payload factory, eg
<payloadFactory>
<format>
<myns:text xmlns:myns="http://myns">$1</myns:text>
</format>
<args>
<arg evaluator="xml" expression="get-property('ERROR_MESSAGE')"/>
</args>
</payloadFactory>
(you shouldn't actually need a namespace definition in the <arg> element)
problem solved :
Replaced ... by
<makefault version="soap11">
<code expression="get-property('ERROR_CODE')"/>
<reason expression="get-property('ERROR_MESSAGE')"/>
</makefault>
and added
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>application/xml</default>
</rules>
</parameter>
just before the end tag.
Don't really know why it works now with this parameter...

How to Know the URL of Client In wso2 esb for Filter

i am doing filter based on the URL so i wish to know the FROM which service i am getting request .Means i wish to know the URL of Client
<proxy xmlns="http://ws.apache.org/ns/synapse" name="Emp" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<property name="username" expression="//username/text()" scope="default" type="STRING"/>
<property name="password" expression="//password/text()" scope="default" type="STRING"/>
<payloadFactory>
<format>
<send xmlns="">
<username>$1</username>
<password>$2</password>
</send>
</format>
<args>
<arg expression="get-property('username')"/>
<arg expression="get-property('password')"/>
</args>
</payloadFactory>
<send receive="Emp_Seq">
<endpoint>
<address uri="http://192.168.1.65:8282/services/Login"/>
</endpoint>
</send>
</inSequence>
<outSequence/>
</target>
<description></description>
</proxy>
URL of above Proxy is http://192.168.1.65:8282/services/Emp
my second proxy is which will do some logic based on first proxy
<proxy xmlns="http://ws.apache.org/ns/synapse" name="Login" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<property name="client_ip_address" expression="get-property('axis2','REMOTE_ADDR')" scope="default" type="STRING"/>
<property name="username" expression="//username/text()" scope="default" type="STRING"/>
<property name="password" expression="//password/text()" scope="default" type="STRING"/>
<property name="From" expression="get-property('From')"/>
<property name="Address" expression="get-property('To')"/>
<filter xmlns:ns="http://org.apache.synapse/xsd" xpath="get-property('From')='/services/Emp'">
<then>
<payloadFactory>
<format>
<ResponseJSON xmlns="">
<Status>404</Status>
<Exception>Not Found</Exception>
<Total>0</Total>
</ResponseJSON>
</format>
</payloadFactory>
<send/>
</then>
<else>
<payloadFactory>
<format>
<p:login xmlns:p="http://authentication.services.core.carbon.wso2.org">
<p:username>$1</p:username>
<p:password>$2</p:password>
<p:remoteAddress>$3</p:remoteAddress>
</p:login>
</format>
<args>
<arg expression="//username/text()"/>
<arg expression="//password/text()"/>
<arg expression="get-property('client_ip_address')"/>
</args>
</payloadFactory>
<header name="Action" value="urn:login"/>
<log level="full"/>
<send receive="Login_Seq">
<endpoint>
<address uri="https://192.168.1.65:9443/services/AuthenticationAdmin" format="soap11"/>
</endpoint>
</send>
</filter>
</inSequence>
<outSequence>
<log level="full"/>
</outSequence>
</target>
<description></description>
</proxy>
The issue is get-property('To') is giving Address=/services/Login where as get-property('From') is giving senderAddress=null
How can i manage this i trie d with lot of propertys even though its not working
like
<property name="senderAddress" expression="get-property('transport', 'From')"/>
<property name="Sender Address" expression="$url:From"/>
<header name="From" expression="get-property( 'From')"/>
<property name="PRESERVE_WS_ADDRESSING" value="true"/>
<property xmlns:wsa="http://www.w3.org/2005/08/addressing" name="$header" expression="$header/wsa:From"/>
This propertys also not working we don't have any option in wso2 esb If you know this please edit my proxy roughly ..its simple depanding logic but it is not working in WSO2
thanks in advance
You should be able to get the client's address with the REMOTE_HOST or REMOTE_ADDR properties. Please refer http://wso2.org/project/esb/java/4.0.3/docs/properties_guide.html#http