In WSO2 configured proxy service, does not send the clinicId param to DSS. In logs from DSS gives exception :
Default Namespace: https://bur.test.ru/dss/services/tfoms
Current Request Name: get_single_inserted_branch_by_id
Current Params: {clinicID=}
Nested Exception:-
java.lang.NumberFormatException: For input string: ""
In logs from ESB:
Nested Exception:-
javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'SQLQuery.processPreNormalQuery': For input string: ""
DS Code: DATABASE_ERROR
Source Data Service:-
Name: TEST
Location: \TEST.dbs
Description: Service generates hospitalisation&
Default Namespace: https://bur.TEST.ru/dss/services/tfoms
Current Request Name: get_single_inserted_branch_by_id
Current Params: {clinicID=}
Nested Exception:-
java.lang.NumberFormatException: For input string: ""
On WSO2 DSS it works good and it takes info from postgres.
Here is a code of proxy servise from WSO2 ESB:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="BurProxy"
transports="http,https"
statistics="disable"
trace="enable"
startOnLoad="true">
<target>
<inSequence>
<property name="CLINIC_ID"
expression="//clinicID/text()"
scope="axis2"
type="STRING"/>
<log level="full">
<property name="CLINIC_ID" expression="clinicID"/>
</log>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tfom="https://bur.cdmarf.ru/dss/services/tfoms">
<soapenv:Header/>
<soapenv:Body>
<tfom:get_single_inserted_branch_by_id>
<tfom:clinicID>$1</tfom:clinicID>
</tfom:get_single_inserted_branch_by_id>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg evaluator="xml" expression="$axis2:CLINIC_ID"/>
</args>
</payloadFactory>
<log>
<property name="PAYLOAD" expression="$body"/>
</log>
<call blocking="true">
<endpoint key="dss"/>
</call>
<xslt key="xslt-remove-namespace"/>
<property name="messageType" value="text/xml" scope="axis2"/>
<property name="contentType" value="text/xml" scope="axis2"/>
<property name="rabbitmq.attributes.app.id"
value="RMIS"
scope="axis2"
type="STRING"/>
<property name="rabbitmq.attributes.type"
value="BRANCH"
scope="axis2"
type="STRING"/>
<property name="rabbitmq.attributes.user.id"
value="rmis"
scope="axis2"
type="STRING"/>
<property name="MESSAGE_ID" expression="get-property('MessageID')"/>
<script language="js">var messageID = mc.getProperty('MESSAGE_ID').substring(9,45);
mc.setProperty("RABBIT_MESSAGE_ID", messageID);</script>
<property name="rabbitmq.attributes.custom.message.id"
expression="get-property('RABBIT_MESSAGE_ID')"
scope="axis2"/>
<clone continueParent="true">
<target sequence="writeToFile"/>
</clone>
<send>
<endpoint key="rabbit"/>
</send>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tfom="https://bur.cdmarf.ru/dss/services/tfoms">
<soapenv:Header/>
<soapenv:Body>
<tfom:get_inserted_divisions_of_clinic>
<tfom:clinicID>$1</tfom:clinicID>
</tfom:get_inserted_divisions_of_clinic>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg evaluator="xml" expression="$axis2:CLINIC_ID"/>
</args>
</payloadFactory>
<call blocking="true">
<endpoint key="dss"/>
</call>
<iterate xmlns:tfoms="https://bur.cdmarf.ru/dss/services/tfoms"
continueParent="true"
expression="//tfoms:DIVISION"
sequential="true">
<target>
<sequence>
<property name="rabbitmq.attributes.type"
value="DIVISION"
scope="axis2"
type="STRING"/>
<property name="messageType" value="xml" scope="axis2"/>
<property name="contentType" value="xml" scope="axis2"/>
<property name="MESSAGE_ID" expression="get-property('MessageID')"/>
<script language="js">var messageID = mc.getProperty('MESSAGE_ID').substring(9,45);
mc.setProperty("RABBIT_MESSAGE_ID", messageID);</script>
<property name="rabbitmq.attributes.custom.message.id"
expression="get-property('RABBIT_MESSAGE_ID')"
scope="axis2"/>
<xslt key="xslt-remove-namespace"/>
<clone continueParent="true">
<target sequence="writeToFile"/>
</clone>
<send>
<endpoint key="rabbit"/>
</send>
</sequence>
</target>
</iterate>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tfom="https://bur.cdmarf.ru/dss/services/tfoms">
<soapenv:Body>
<tfom:get_inserted_liks_division_to_bed>
<tfom:clinicID>$1</tfom:clinicID>
</tfom:get_inserted_liks_division_to_bed>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg evaluator="xml" expression="$axis2:CLINIC_ID"/>
</args>
</payloadFactory>
<call blocking="true">
<endpoint key="dss"/>
</call>
<iterate xmlns:tfoms="https://bur.cdmarf.ru/dss/services/tfoms"
continueParent="true"
expression="//tfoms:DIVISION_LINK_STRUCTURE_BED"
sequential="true">
<target>
<sequence>
<property name="rabbitmq.attributes.type"
value="DIVISION_LINK_STRUCTURE_BED"
scope="axis2"
type="STRING"/>
<property name="messageType" value="xml" scope="axis2"/>
<property name="contentType" value="xml" scope="axis2"/>
<property name="MESSAGE_ID" expression="get-property('MessageID')"/>
<script language="js">var messageID = mc.getProperty('MESSAGE_ID').substring(9,45);
mc.setProperty("RABBIT_MESSAGE_ID", messageID);</script>
<property name="rabbitmq.attributes.custom.message.id"
expression="get-property('RABBIT_MESSAGE_ID')"
scope="axis2"/>
<xslt key="xslt-remove-namespace"/>
<clone continueParent="true">
<target sequence="writeToFile"/>
</clone>
<send>
<endpoint key="rabbit"/>
</send>
</sequence>
</target>
</iterate>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tfom="https://bur.cdmarf.ru/dss/services/tfoms">
<soapenv:Body>
<tfom:get_inserted_amound_bed>
<tfom:clinicID>$1</tfom:clinicID>
</tfom:get_inserted_amound_bed>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg evaluator="xml" expression="$axis2:CLINIC_ID"/>
</args>
</payloadFactory>
<call blocking="true">
<endpoint key="dss"/>
</call>
<iterate xmlns:tfoms="https://bur.cdmarf.ru/dss/services/tfoms"
continueParent="true"
expression="//tfoms:AMOUNT_BED"
sequential="true">
<target>
<sequence>
<property name="rabbitmq.attributes.type"
value="AMOUNT_BED"
scope="axis2"
type="STRING"/>
<property name="messageType" value="xml" scope="axis2"/>
<property name="contentType" value="xml" scope="axis2"/>
<property name="MESSAGE_ID" expression="get-property('MessageID')"/>
<script language="js">var messageID = mc.getProperty('MESSAGE_ID').substring(9,45);
mc.setProperty("RABBIT_MESSAGE_ID", messageID);</script>
<property name="rabbitmq.attributes.custom.message.id"
expression="get-property('RABBIT_MESSAGE_ID')"
scope="axis2"/>
<xslt key="xslt-remove-namespace"/>
<clone continueParent="true">
<target sequence="writeToFile"/>
</clone>
<send>
<endpoint key="rabbit"/>
</send>
</sequence>
</target>
</iterate>
<respond/>
</inSequence>
</target>
<description/>
</proxy>
For a request like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tfom="bur.cdmarf.ru/dss/services/tfoms">
<soapenv:Header/>
<soapenv:Body>
<tfom:get_inserted_amound_bed>
<tfom:clinicID>6048820</tfom:clinicID>
</tfom:get_inserted_amound_bed>
</soapenv:Body>
</soapenv:Envelope>
Yo can use this mediators to capture and log the clinic_id value:
<property name="CLINIC_ID" xmlns:tfom="bur.cdmarf.ru/dss/services/tfoms"
expression="//tfom:get_inserted_amound_bed/tfom:clinicID"
scope="default"
type="STRING"/>
<log level="custom">
<property name="CLINIC_ID_PROPERTY_VALUE" expression="get-property('CLINIC_ID')"/>
</log>
<log>
<property name="PAYLOAD" expression="$body"/>
</log>
In the payload factory mediator use the same expression to capture the clinic id value:
<args>
<arg evaluator="xml" expression="get-property('CLINIC_ID')"/>
</args>
Related
I'm trying to get access token through AWS Cognito with client credentials but getting something else.
I'm doing this in wso2 Enterprise integrator 6.1.0
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema/instance">
<soapenv:Header>
<Content-Type xmlns="">$1</Content-Type>
<Authorization xmlns="">$2</Authorization>
</soapenv:Header>
<soapenv:Body/>
</soapenv:Envelope>
</format>
<args>
<arg evaluator="xml" value="application/x-www-form-urlencoded"/>
<arg value="Basic 2354sdfmdtrerkdfdgkeryryrtwdasr345345twsdfwsedtr34"/>
</args>
</payloadFactory>
<log level="full"/>
<property name="DISABLE_CHUNKING" scope="axis2" type="STRING" value="true"/>
<endpoint key="validateUser-ext-ep"/>
</call>
<log level="full"/>
after this the response i'm getting is like this :
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<ns:binary xmlns:ns="http://ws.apache.org/commons/ns/payload">PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbiYWNrZ3JvdW5kLWN1c3RvbWl6YWJsZSBtb2RhbC1jb250ZW50LW1vYmlsZSI+CiAgICAgICAgICAgICAgICA8ZGl2PgogICAgICAgICAgICAgICAgICAgIDxkaXYgY2xhc3M9ImJhbm5lci1jdXN0b21pemFibGUiPgogICAgICAgICAgICAgICAgICAgICAgICA8Y2VudGVyPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgIDwvY2VudGVyPgogICAgICAgICAgICAgICAgICAgIDwvZGl2PgogICAgICAgICAgICAgICAgPC9kaXY+CiAgICAgICAgICAgICAgICA8ZGl2IGNsYXNzPSJtb2RhbC1ib2R5Ij4KICAgICAgICAgICAgICAgICAgICA8cCBhbGlnbj0iY2VudGVyIj5BbiBlcnJvciB3YXMgZW5jb3VudGVyZWQgd2l0aCB0aGUgcmVxdWVzdGVkIHBhZ2UuPC9wPgogICAgICAgICAgICAgICAgICAgIDxicj4KICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgIDwvZGl2PgogICAgICAgICAgICA8L2Rpdj4KICAgICAgICA8L2Rpdj4KICAgIDwvZGl2Pgo8L2JvZHk+Cgo8L2h0bWw+Cg==</ns:binary>l
</soapenv:Body>
</soapenv:Envelope>
I don't know if I'm doing something wrong as in postman I sent the data same way I was getting the token there I passed the Authrization as Basic dfudne4r49859dfnw34598sdfs base64 endcoded(client:client_secret) and Content-Type : application/x-www-form-urlencoded in header and in params I passed grant_type: client_credential for this I was able to get the token but when I tried in wso2 esb I got the above error
the endpoint looks like :https://xxxxxxxxxx.us-east-1.amazoncognito.com/oauth2/token?grant_type=client_credentials
this is the API to get the Access token and it returns the access token
<?xml version="1.0" encoding="UTF-8"?>
<api context="/api/myService" name="my-service-api" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST" uri-template="/getToken">
<inSequence>
<script language="js"><![CDATA[var payload = mc.getPayloadXML();
var log = mc.getServiceLog();
var client_id = payload..*::client_id.toString();
var client_secret = payload..*::client_secret.toString();
mc.setProperty("client_id", client_id);
mc.setProperty("client_secret", client_secret);]]>
</script>
<payloadFactory media-type="json">
<format/>
<args/>
</payloadFactory>
<property name="ContentType" scope="axis2" type="STRING" value="application/x-www-form-urlencoded"/>
<property expression="fn:concat($ctx:client_id,':',$ctx:client_secret)" name="credentials" scope="default" type="STRING"/>
<property expression="fn:concat('Basic ', base64Encode($ctx:credentials))" name="Authorization" scope="transport" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
<property name="FORCE_POST_PUT_NOBODY" scope="axis2" type="BOOLEAN" value="true"/>
<property name="DISABLE_CHUNKING" scope="axis2" type="STRING" value="true"/>
<call>
<endpoint>
<http method="post" uri-template="https://xxxxxxxxxxx.amazoncognito.com/oauth2/token?grant_type=client_credentials"/>
</endpoint>
</call>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
Call the above API like this :
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<root>
<client_id>$1</client_id>
<client_secret>$2</client_secret>
</root>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg evaluator="xml" expression="get-property('client_id')"/>
<arg evaluator="xml" expression="get-property('client_secret')"/>
</args>
</payloadFactory>
<property name="ContentType" scope="default" type="STRING" value="application/xml"/>
<property action="remove" name="REST_URL_POSTFIX" scope="axis2"/>
<call>
<endpoint>
<http method="post" uri-template="http://localhost:8280/api/myService/getToken"/>
</endpoint>
</call>
<script language="js">
<![CDATA[ var tokenContainer = mc.getPayloadJSON();
var log = mc.getServiceLog();
mc.setProperty("Authorization_header", tokenContainer.access_token);]]>
</script>
The Response will be
{"access_token":"LzSq94JoaUT2LwJlkEl35CXX0MdwqtUKIL8Wvi7dm4SqcSofR4xF5xBZre83MZXpHOr-Hg","expires_in":360,"token_type":"Bearer"}
In last script mediator you can access the token Access token throught getting it by mc.getPayloadJSON() this will give the same response as shwon above
I'm using WSO2 EI 6.3v.I want to pass application/x-www-form-urlencoded data to the rezlive hotel Supplier. In hear i put my code and response.
CODE
<inSequence>
<log category="WARN" level="full">
<property name="API BEGIN" value="Test_Supplier API"/>
</log>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<HotelFindRequest xmlns="">
$1
</HotelFindRequest>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg evaluator="xml" expression="$env/*[local-name()='Body']/*[local-name()='HotelFindRequest']/*"/>
</args>
</payloadFactory>
<property expression="$env/*[local-name()='Body']/*" name="xmlbody" scope="default" type="STRING"/>
<log>
<property expression="$ctx:xmlbody" name="Body======="/>
</log>
<property name="messageType" scope="axis2" type="STRING" value="application/x-www-form-urlencoded"/>
<property expression="$body" name="payload" scope="default" type="STRING"/>
<property name="uri.var.url" scope="default" type="STRING" value="http://test.xmlhub.com/testpanel.php/action/findhotel"/>
<call>
<endpoint>
<address format="pox" uri="http://test.xmlhub.com/testpanel.php/action/findhotel?XML={xmlbody}"/>
</endpoint>
</call>
<respond/>
</inSequence>
Body Log
<HotelFindRequest>
<Authentication>
<AgentCode>xxxxxxx</AgentCode>
<UserName>xxxxx</UserName>
<Password>xxxxxx</Password>
</Authentication>
<Booking>
<ArrivalDate>22/05/2019</ArrivalDate>
<DepartureDate>25/05/2019</DepartureDate>
<CountryCode>AE</CountryCode>
<City>968</City>
<GuestNationality>LK</GuestNationality>
<HotelRatings>
<HotelRating>1</HotelRating><HotelRating>2</HotelRating>
<HotelRating>3</HotelRating><HotelRating>4</HotelRating>
<HotelRating>5</HotelRating>
</HotelRatings>
<Rooms>
<Room>
<Type>Room-1</Type>
<NoOfAdults>2</NoOfAdults>
<NoOfChilds>0</NoOfChilds>
</Room>
<Room>
<Type>Room-2</Type>
<NoOfAdults>1</NoOfAdults>
<NoOfChilds>0</NoOfChilds>
</Room>
<Room>
<Type>Room-3</Type>
<NoOfAdults>2</NoOfAdults>
<NoOfChilds>0</NoOfChilds>
</Room>
<Room>
<Type>Room-4</Type>
<NoOfAdults>3</NoOfAdults>
<NoOfChilds>0</NoOfChilds>
</Room>
</Rooms>
</Booking>
Response comming as
<HotelFindResponse>
<error>Please provide agentcode.</error>
<error>Please provide username.</error>
<error>Please provide password.</error></HotelFindResponse>
But I pass same configuration in POSTMAN, give me the correct response.
I put the same configuration in Postman. I tried so meny ways to get response.All are failed.
What is wrong with that code?.
Please help.
Can you try with HTTP endpoint (https://docs.wso2.com/display/EI640/HTTP+Endpoint) using post?
Payload factory already sets the body, so it should work right away as it will try to post it.
Try using "uri.var.xmlBody" property name instead of simple "xmlBody":
<property expression="$env/*[local-name()='Body']/*" name="uri.var.xmlBody" scope="default" type="STRING"/>
<call>
<endpoint>
<address format="pox" uri="http://test.xmlhub.com/testpanel.php/action/findhotel?XML={uri.var.xmlBody}"/>
</endpoint>
</call>
Can you try this? from here
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<root xmlns="">
<XML>$1</XML>
</root>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg evaluator="xml" expression="$ctx:xmlbody"></arg>
</args>
</payloadFactory>
<property name="messageType" value="application/x-www-form-urlencoded" scope="axis2" type="STRING"></property>
<property name="DISABLE_CHUNKING" value="true" scope="axis2" type="STRING"></property>
<call>
<http method="post" uri-template="test.xmlhub.com/testpanel.php/action/findhotel"/>
</call>
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.
I am really worrying about this future.If your developing some product like middleware you should aware of all the future like transaction,sec,.etc
security is good in wso2 where as transactions are really poor
i am using wso2esb4.8.0 and wso2dss3.0.1 .I wish to insert the data into my 2 tables simple logic if my 2nd table went wrong my first table also roll backed.For this i used wso2dss Box-carring future and its perfectly fine while i am doing from wso2dss try-it .BUt same future i wish to incorporate with wso2esb .i call 4 operation like beginboxcarring,insertintot1,insertintot2,endboxcarring but its not working in this then i got sloution with get JSESSIONID which will create when call a beginboxcarring but there is no use i tried with this properties to get JSESSIONID
and my proxy is
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="TransactionProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full">
<property name="M1" value="*************HITTING Transaction PROXY*************"/>
</log>
<property name="OUT_ONLY" value="true"/>
<property name="companycode" expression="//companycode/text()"/>
<property name="companyname" expression="//companyname/text()"/>
<property name="clientcode" expression="//clientcode/text()"/>
<property name="clientname" expression="//clientname/text()"/>
<property name="session type"
value="JSESSIONID"
scope="default"
type="STRING"/>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:dat="http://ws.wso2.org/dataservice">
<soapenv:Header/>
<soapenv:Body/>
</soapenv:Envelope>
</format>
<args/>
</payloadFactory>
<log level="full">
<property name="M2" value="*************HITTING Transaction PROXY*************"/>
</log>
<header name="Action" value="urn:begin_boxcar"/>
<property name="setCookieHeader"
expression="$trp:Set-Cookie"
scope="default"
type="STRING"/>
<callout serviceURL="http://localhosttt:9764/services/Transaction/begin_boxcar"
action="urn:begin_boxcar">
<source type="envelope"/>
<target xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
</callout>
<property name="setCookieHeader"
expression="$trp:Set-Cookie"
scope="default"
type="STRING"/>
<log level="full">
<property name="JSESSIONID" expression="get-property('setCookieHeader')"/>
</log>
<payloadFactory media-type="xml">
<format>
<p:insertinto_mclient_OP xmlns:p="http://ws.wso2.org/dataservice">
<xs:clientcode xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:clientcode>
<xs:clientname xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:clientname>
<xs:createdbyid xmlns:xs="http://ws.wso2.org/dataservice">-1</xs:createdbyid>
<xs:modifiedbyid xmlns:xs="http://ws.wso2.org/dataservice">-1</xs:modifiedbyid>
</p:insertinto_mclient_OP>
</format>
<args>
<arg evaluator="xml" expression="get-property('clientcode')"/>
<arg evaluator="xml" expression="get-property('clientname')"/>
</args>
</payloadFactory>
<header name="Action" value="urn:insertinto_mclient_OP"/>
<callout serviceURL="http://localhosttt:9764/services/Transaction/"
action="urn:insertinto_mclient_OP">
<source xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
<target xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
</callout>
<payloadFactory media-type="xml">
<format>
<p:insertinto_mcompany_OP xmlns:p="http://ws.wso2.org/dataservice">
<xs:companycode xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:companycode>
<xs:comapnyname xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:comapnyname>
<xs:createdbyid xmlns:xs="http://ws.wso2.org/dataservice">-1</xs:createdbyid>
<xs:modifiedbyid xmlns:xs="http://ws.wso2.org/dataservice">-1</xs:modifiedbyid>
<xs:clientid xmlns:xs="http://ws.wso2.org/dataservice">-1</xs:clientid>
</p:insertinto_mcompany_OP>
</format>
<args>
<arg evaluator="xml" expression="get-property('companycode')"/>
<arg evaluator="xml" expression="get-property('companyname')"/>
</args>
</payloadFactory>
<log level="full">
<property name="M5" value="**************hitting2nd dss*****"/>
</log>
<header name="Action" value="urn:insertinto_mcompany_OP"/>
<callout serviceURL="http://localhosttt:9764/services/Transaction/"
action="urn:insertinto_mcompany_OP">
<source xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
<target xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
</callout>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:dat="http://ws.wso2.org/dataservice">
<soapenv:Header/>
<soapenv:Body/>
</soapenv:Envelope>
</format>
<args/>
</payloadFactory>
<log level="full">
<property name="M3" value="*************HITTING Transaction PROXY*************"/>
</log>
<header name="Action" value="urn:end_boxcar"/>
<callout serviceURL="http://localhosttt:9764/services/Transaction/end_boxcar"
action="urn:end_boxcar">
<source type="envelope"/>
<target xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
</callout>
<log level="full">
<property name="M4" value="*************HITTING Transaction PROXY*************"/>
</log>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<description/>
</proxy>
but log is showing JSESSIONID=null
and even i tried this properties also no change in log
<property name="setCookieHeader"
expression="get-property('transport','Set-Cookie')"
scope="default"
type="STRING"/>
<property name="setCookieHeader5"
expression="get-property('transport','JSESSIONID')"
scope="default"
type="STRING"/>
how would i get if i call from CURL the dss operation begin_boxcarring end point giving like this in header
Set-Cookie: JSESSIONID=6776AC50E31EBFC456CDA1895ACDE0B8; Path=/; HttpOnly
but unable to get into synapse how would i get .is there any option for transaction really worried about this future in wso2
i want handle error using fault sequence but i wish to customize it with delete operation
my scenario is while i am inserting in 2 tables if error occurred in 2nd table insertion i need to delete 1 st row insertion also my config is below
<proxy xmlns="http://ws.apache.org/ns/synapse" name="ErrorHandling" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target >
<inSequence onError="fault">
<property name="eno" expression="//eno/text()" scope="default" type="STRING"/>
<property name="ename" expression="//ename/text()" scope="default" type="STRING"/>
<property name="esal" expression="//esal/text()" scope="default" type="STRING"/>
<property name="deptname" expression="//deptname/text()" scope="default" type="STRING"/>
<property name="deptid" expression="//deptid/text()" scope="default" type="STRING"/>
<payloadFactory>
<format>
<p:insert_emp_operation xmlns:p="http://ws.wso2.org/dataservice">
<xs:eno xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:eno>
<xs:ename xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:ename>
<xs:esal xmlns:xs="http://ws.wso2.org/dataservice">$3</xs:esal>
</p:insert_emp_operation>
</format>
<args>
<arg expression="get-property('eno')"/>
<arg expression="get-property('ename')"/>
<arg expression="get-property('esal')"/>
</args>
</payloadFactory>
<send receive="Error_Seq">
<endpoint>
<address uri="http://localhost:9764/services/emp_DataService/" format="soap11"/>
</endpoint>
</send>
<log level="full"/>
</inSequence>
<outSequence onError="fault">
<send/>
<log level="full"/>
</outSequence>
</target>
<description></description>
</proxy>
and sequence is like this
<sequence xmlns="http://ws.apache.org/ns/synapse" name="Error_Seq" onError="fault">
<property xmlns:f="http://ws.wso2.org/dataservice" xmlns:ns="http://org.apache.synapse/xsd" name="ID" expression="//f:ID/text()" scope="default" type="STRING"/>
<log>
<property xmlns:ns="http://org.apache.synapse/xsd" name="faisal" expression="get-property('ID')"/>
</log>
<payloadFactory>
<format>
<p:insert_dept_operation xmlns:p="http://ws.wso2.org/dataservice">
<xs:deptno xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:deptno>
<xs:deptname xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:deptname>
<xs:deptid xmlns:xs="http://ws.wso2.org/dataservice">$3</xs:deptid>
</p:insert_dept_operation>
</format>
<args>
<arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('ID')"/>
<arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('deptname')"/>
<arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('deptid')"/>
</args>
</payloadFactory>
<send>
<endpoint>
<address uri="http://localhost:9764/services/dept_DataService/" format="soap11"/>
</endpoint>
</send>
</sequence>
fault sequenceis like this
<sequence xmlns="http://ws.apache.org/ns/synapse" name="fault">
<property xmlns:ns="http://org.apache.synapse/xsd" name="ID" expression="get-property('ID')" scope="default" type="STRING"/>
<log level="full">
<property name="MESSAGE" value="Executing default 'fault' sequence"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="Property" expression="get-property('ID')"/>
</log>
<payloadFactory>
<format>
<p:Delete_Op xmlns:p="http://ws.wso2.org/dataservice">
<xs:eno xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:eno>
</p:Delete_Op>
</format>
</payloadFactory>
<send>
<endpoint>
<address uri="http://localhost:9764/services/dept_DataService/" format="soap11"/>
</endpoint>
</send>
</sequence>
but its not working its working while the DSS Is in OFF mode let me know when DSS is In Running mode how to delete the 1st table row
In your scenario when update fails at DSS, it will send back a SOAP fault to the ESB.
Since ESB this is still just another message response, and it will not goto the fault sequence, unless you explicitly check the message and do the necessary actions.
So you have to declare comming message is a SOAP_FAULT so you hace to say it is a SOAP_FAULT and force it to error sequance. This is explained in [1].
[1] http://maharachchi.blogspot.com/2012/09/now-you-can-send-soapfaults-to-fault.html