I have a problem to parse the callout response of a dss.
I have 2 servers
WSO2 ESB server (4.9.0)
WSO2 Application Server (5.3.0) with Data Service (4.3.4) feature installed
i make a payload
<payloadFactory description="Payload Processed" media-type="xml">
<format>
<p:archivoProcesado xmlns:p="MyDataService">
<xs:archivo xmlns:xs="MyDataService">$1</xs:archivo>
</p:archivoProcesado>
</format>
<args>
<arg evaluator="xml" expression="get-property('filename')" />
</args>
</payloadFactory>
After that i make a callout
<callout action="archivoProcesado" description="Callout ArchivoProcesado"
initAxis2ClientOptions="false"
serviceURL="http://192.168.0.33:9764/services/MyDataService?wsdl">
<source xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]" />
<target xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]" />
</callout>
To test the result i have:
<log level="custom">
<property expression="$body/*" name="RTA" />
</log>
And have:
LogMediator RTA = <ArchivosProcesados xmlns="MyDataService"><ArchivoProcesado><procesado>1</procesado></ArchivoProcesado></ArchivosProcesados>
but when i want to parse the response i cant
<log level="custom">
<property expression="//ArchivosProcesados/ArchivoProcesado/procesado/text()"
name="count" />
</log>
<log level="custom">
<property expression="//ArchivosProcesados" name="xxx" />
</log>
<log level="custom">
<property expression="//ArchivosProcesados/*" name="yyy" />
</log>
and the log is blank
INFO - LogMediator count =
INFO - LogMediator xxx =
INFO - LogMediator yyy =
How can i get the value? what am i doing wrong?
MyDSS
<query id="archivoProcesado" useConfig="MyDataService">
<sql>select count(1) as procesado from auto_procesados where archivo = ?</sql>
<param name="archivo" ordinal="1" paramType="SCALAR" sqlType="STRING" type="IN"/>
<result element="ArchivosProcesados" rowName="ArchivoProcesado">
<element column="procesado" name="procesado"/>
</result>
</query>
<operation name="archivoProcesado">
<call-query href="archivoProcesado">
<with-param name="archivo" query-param="archivo"/>
</call-query>
</operation>
In ESB 4.9.0 we have depricated the callout mediator. So could you please use call mediator [1] with [blocking="true"] instead. If it is not working please enable wirelogs as per [2] and check whether you are getting the response from the DSS endpoint properly. A sample call mediator configuration would be as follows.
<call blocking="true">
<endpoint>
<address format="soap12" uri="http://192.168.0.33:9764/services/MyDataService"/>
</endpoint>
</call>
Also when you get the data from DSS all the data falls under the following name space. http://ws.wso2.org/dataservice. You will have to define a namespace prefix to that namespace and use that in your xpath expressions. An example is given below.
<log level="custom">
<property xmlns:x="http://ws.wso2.org/dataservice" expression="//x:ArchivosProcesados/x:ArchivoProcesado/x:procesado/text()"
name="count" />
</log>
[1] https://docs.wso2.com/display/ESB490/Call+Mediator
[2] http://mytecheye.blogspot.com/2013/09/wso2-esb-all-about-wire-logs.html
Try adding the xmlns attribute to the property mediator.
<log level="custom">
<property xmlns="MyDataService" expression="//ArchivosProcesados/ArchivoProcesado/procesado/text()"
name="count" />
</log>
JP
First of all i change the callout by a blocking call.
After that i change the messageType to json
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
and then access through json-eval
<property expression="json-eval($.ArchivosProcesados.ArchivoProcesado.procesado)"
name="count" scope="default" type="STRING"/>
Finally i back the message type to xml:
<property name="messageType" scope="axis2" type="STRING" value="text/xml"/>
Related
I have created a data service on Enterprise Integrator that searches a microsoft sql server database for a usercode, if the usercode I am searching for exists in the db the response is the users first name and last name. Is it possible for the user to get redirected to a c# webpage instead of their first name and last name being returned?
I am then calling my data service with my rest api, my intention is to search an microsft sql db and if the data is in the db I should be redirected to a c# webpage. However when I try to test my API I am getting back my json from the Result (Output Mapping) in my query from my data service. I am unsure how to resolve the conflict and any assistance would be greatly appreciated.
My Data Service Code:
`
<data name="restds" transports="http https">
<config enableOData="false" id="restdb">
<property name="carbon_datasource_name">REST</property>
</config>
<query id="query2" useConfig="restdb">
<sql>select UserCode,FirstName,LastName from UserDB.dbo.Users where UserCode=?</sql>
<result outputType="json" useColumnNumbers="true"> {
"users": {
"user": [
{
"UserCode": "$1",
"FirstName": "$2",
"LastName": "$3"
}
]
}
}
</result>
<param name="UserCode" optional="false" sqlType="STRING"/>
</query>
<resource method="GET" path="Users">
<call-query href="query2">
<with-param name="UserCode" query-param="UserCode"/>
</call-query>
</resource>
</data>
My REST API Code:
`<api xmlns="http://ws.apache.org/ns/synapse" name="DSAPI2" context="/dsapi2">
<resource methods="GET" uri-template="/{UserCode}">
<inSequence>
<call>
<endpoint>
<http method="GET" uri-template="http://localhost:8280/services/restds/Users"/>
</endpoint>
</call>
<filter xpath="$body//FirstName/text() != ''">
<then>
<log>
<property name="Message" value="Name Exists Lets redirect"/>
</log>
<property name="HTTP_SC" value="302" scope="axis2" type="STRING"/>
<property name="Location" value="https://wso2.com/" scope="transport" type="STRING"/>
</then>
<else>
<log>
<property name="HTTP_SC" value="302"/>
<property name="Location" value="https://www.youtube.com/"/>
</log>
</else>
</filter>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
`
I was expecting to redirect when testing the API, however the response body I am getting is:
{
"users": {}
}
Which is from the json in my data service
You can't do that in the dataservice. In REST API on Integration studio, while you get successful response, you can use HTTP redirect 302. Use property HTTP_SC with 302 code and http header with Location like below:
<property name="HTTP_SC" scope="axis2" type="STRING" value="302"/>
<property name="Location" value="https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections" scope="transport" type="STRING"/>
You can set the Location address to your c# website.
But I am not sure, if that that solution is not too awkward.
See docs:
Web/HTTP/Redirections and Web/HTTP/Headers/Location
As tmoasz mentioned. You can't do it in the Dataservice, what you can do is interface the Dataservice with an API and handle the redirection logic there. You don't have to use DbLookup or additional mediators to connect to the DB. Simply call your Dataservice from the API. Something like below.
<?xml version="1.0" encoding="UTF-8"?>
<api context="/checkuser" name="YOURAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET">
<inSequence>
<call>
<endpoint>
<http method="get" uri-template="http://localhost:8290/rcsrest/Users">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>-1</progressionFactor>
<maximumDuration>0</maximumDuration>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</http>
</endpoint>
</call>
<filter xpath="$body//FirstName/text() != ''">
<then>
<log>
<property name="Message" value="Name Exists Lets redirect"/>
</log>
<property name="HTTP_SC" scope="axis2" type="STRING" value="302"/>
<property name="Location" value="https://to-someplace" scope="transport" type="STRING"/>
</then>
<else>
<log>
<property name="Message" value="Name is empty no redirection"/>
</log>
</else>
</filter>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
Update
Adding the Query Param to the Payload.
Note: GET request will not allow you to send Payloads in the request body, hence change the Dataservice method to a POST as well.
Dataservice
<data name="restds" transports="http https">
<config enableOData="false" id="restdb">
<property name="carbon_datasource_name">REST</property>
</config>
<query id="query2" useConfig="restdb">
<sql>select UserCode,FirstName,LastName from UserDB.dbo.Users where UserCode=?</sql>
<result outputType="json" useColumnNumbers="true"> {
"users": {
"user": [
{
"UserCode": "$1",
"FirstName": "$2",
"LastName": "$3"
}
]
}
}
</result>
<param name="UserCode" optional="false" sqlType="STRING"/>
</query>
<resource method="POST" path="Users">
<call-query href="query2">
<with-param name="UserCode" query-param="UserCode"/>
</call-query>
</resource>
</data>
API
<api xmlns="http://ws.apache.org/ns/synapse" name="DSAPI2" context="/dsapi2">
<resource methods="GET" uri-template="/{UserCode}">
<inSequence>
<payloadFactory media-type="xml">
<format>
<body xmlns="">
<p:_getusers xmlns:p="ws.wso2.org/dataservice/query2">
<xs:UserCode xmlns:xs="ws.wso2.org/dataservice/query2">$1</xs:UserCode>
</p:_getusers>
</body>
</format>
<args>
<arg evaluator="xml" expression="$url:UserCode"/>
</args>
</payloadFactory>
<call>
<endpoint>
<http method="POST" uri-template="http://localhost:8280/services/restds/Users"/>
</endpoint>
</call>
<filter xpath="$body//FirstName/text() != ''">
<then>
<log>
<property name="Message" value="Name Exists Lets redirect"/>
</log>
<property name="HTTP_SC" value="302" scope="axis2" type="STRING"/>
<property name="Location" value="https://wso2.com/" scope="transport" type="STRING"/>
</then>
<else>
<log>
<property name="HTTP_SC" value="302"/>
<property name="Location" value="https://www.youtube.com/"/>
</log>
</else>
</filter>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
When using property mediator pattern i am getting internal server error
<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="regex">
<log level="custom">
<property name="log" value="******************************"/>
</log>
<property name="regex" expression="$url:regex" scope="default"
type="string" pattern="(.|\s)*\S(.|\s)*" group="2"/>
<property name="service_ep"
value="http://www.mocky.io/v2/5d0086223200007700f9d561" />
<header name="To" expression="get-property('service_ep')" />
<log level="full"/>
</sequence>
Response what i am getting :
<am:fault xmlns:am="http://wso2.org/apimanager">
<am:code>0</am:code>
<am:type>Status report</am:type>
<am:message>Runtime Error</am:message>
<am:description>Unknown type : string for the property mediator or the
property value cannot be converted into the specified type.
</am:description>
</am:fault>
The type should be in block letters.
<property name="regex" expression="$url:regex" scope="default"
type="STRING" pattern="(.|\s)*\S(.|\s)*" group="2"/>
Please refer to this documentation. https://docs.wso2.com/display/EI650/Property+Mediator#PropertyMediator-ConfigurationConfigs
In our test environment we build a one-way proxy service that uses callout to get data from several other services. Now when one of those services fails wso2 proxy sends 202 accepted anyway. Is it possible to "catch exceptions" and return a different status?
I know that in this case it would be better to use a request-response proxy, but even if we would create a proxy that only stores the payload in a messagestore there could be issues regarding database where the payload would be stored (database is down, etc) and we don't want status 202 to be returned if the message was not stored in db.
edit:
Here is my proxy after changes suggested in first answer to my question:
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="notifyOfClaimChangeOut" serviceGroup="" startOnLoad="true"
trace="disable" transports="http https" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<property description="OUT_ONLY" name="OUT_ONLY" scope="default"
type="BOOLEAN" value="true"/>
<property name="FORCE_ERROR_ON_SOAP_FAULT" scope="default"
type="STRING" value="true"/>
<property description="OriginalPayload" expression="$body"
name="OriginalPayload" scope="default" type="STRING"/>
<iterate description=""
expression="$body//InsClaimData/PartnerList/PartnerEntry" id="" sequential="true">
<target>
<sequence>
<payloadFactory description="" media-type="xml">
<format>
<plat:FindCustomerSync xmlns:plat="http://platform.###.pl/">
<plat:request>
<plat:FirstName>$1</plat:FirstName>
<plat:LastName>$2</plat:LastName>
<plat:Pesel>$3</plat:Pesel>
</plat:request>
</plat:FindCustomerSync>
</format>
<args>
<arg evaluator="xml" expression="$body/PartnerEntry/BusinessPartner/personData/firstName"/>
<arg evaluator="xml" expression="$body/PartnerEntry/BusinessPartner/personData/lastName"/>
<arg evaluator="xml" expression="$body/PartnerEntry/BusinessPartner/personData/PESEL"/>
</args>
</payloadFactory>
<log level="custom">
<property expression="$body" name="property_name"/>
</log>
<callout action="http://platform.###.pl/FindCustomerSync"
description="QueryCustomersOut"
endpointKey="gov:###/endpoints/###/QueryCustomersOut.xml" initAxis2ClientOptions="false">
<source type="envelope"/>
<target key="QueryCustomersOutResponse"/>
</callout>
<log description="" level="custom" separator=",">
<property expression="$ctx:QueryCustomersOutResponse"
name="QueryCustomersOut"
xmlns:cla="http://###.###.io/service/internal/ClaimService" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"/>
</log>
</sequence>
</target>
</iterate>
<!--
<callout description="ClaimService"
endpointKey="gov:###/endpoints/###/ClaimService.xml" initAxis2ClientOptions="false">
<source type="envelope"/>
<target key="ClaimServiceResponse"/>
</callout>
<log description="ClaimService Response" level="custom">
<property expression="$ctx:ClaimServiceResponse" name="ClaimServiceResponse"/>
</log>
-->
<drop/>
</inSequence>
<outSequence/>
<faultSequence>
<property name="HTTP_SC" scope="axis2" type="STRING" value="500"/>
<log>
<property name="Error" value="Fault :("/>
</log>
</faultSequence>
</target>
<publishWSDL key="gov:###/schemas/###/ClaimService.wsdl"/>
</proxy>
You can use the HTTP_SC property to send status 500. You'll also need the makefault mediator to construct the fault message.
<property name="HTTP_SC" value="500" scope="axis2"/>
<makefault version="soap11">
You can refer this jira to get an idea.
In addition, in the inSequence, you may need to set FORCE_ERROR_ON_SOAP_FAULT property to move to the fault sequence when a soap fault occurs. Some explanation available here.
<inSequence>
<property name="FORCE_ERROR_ON_SOAP_FAULT" value="true" scope="default" type="STRING"/>
</inSequence>
I am having a slight issue with 2 sequence's I have created in a WSO2 Esb proxy service.
Here is my configuration:
My Proxy (Pepkor_Product_Search_Proxy) needs to search a web service and data service for product information and bring back the response(aggregated if need be).
My Proxy service calls 2 services ; a data service hosted on the DSS and a Web service hosted on the AS. The proxy request is sent to 2 "request sequences" that format the request to match the expected messages of the respective service calls on the AS and DSS. Once the responses are received , I send them to the 2 "response sequences" in order to format them according(in line with the WSDL) to the proxy service response. However once reaching the send mediators in these sequences , execution stops and they are not received by the Out Sequence of the proxy.
The send mediators are using the default behavior( which should be to send to out sequence of proxy) such as :
All 4 sequences( 2 Rq + 2Rs ) are dynamic and saved in system_/conf: registry
I recieve the message back in soap from only the one service ( it seems the rs sequences are responding and not the out seq of proxy!)
I want to know how I can get these "mediated" responses back into my proxies out sequence...
I have tried the sequence mediator instead of clone but to no avail.
Please see below : the Rq mssg , the proxy and "response" sequences synapse configurations as well as the proxy carbon log.
Thanks in advance and is there any other info you need let me know.
SOAP Rq:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:prod="http://za.co.pepkor/product_service/">
<soapenv:Header/>
<soapenv:Body>
<prod:productSearchReq>
<!--Optional:-->
<productName>NIKE_SHIRTS</productName>
<!--Optional:-->
<productSize>7</productSize>
<!--Optional:-->
<productColour>RED</productColour>
</prod:productSearchReq>
</soapenv:Body>
</soapenv:Envelope>
Proxy:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="Pepkor_Product_Search_Proxy"
transports="https http" startOnLoad="true" trace="disable">
<target>
<inSequence>
<log level="custom">
<property name="Sending request to :"
value="ackServiceSearchSeqRq and shcServiceSearchSeqRq sequences..." />
</log>
<clone sequential="true">
<target sequence="conf:/ackServiceSearchSeqRq" />
<target sequence="conf:/shcServiceSearchSeqRq" />
</clone>
</inSequence>
<outSequence>
<log level="custom">
<property name="Out Sequence reached"
value="++++++++++++++=========Aggregating now========+++++++++++++++++==" />
</log>
<aggregate>
<completeCondition>
<messageCount min="-1" max="-1" />
</completeCondition>
<onComplete expression="//productDetails">
<log level="custom" separator=",">
<property name="::::"
value="======================= Sending Back the Aggregated Responses. ===============" />
</log>
</onComplete>
</aggregate>
<respond />
</outSequence>
<faultSequence />
</target>
<publishWSDL key="gov:service_integration/wsdls/PepKorProductSearch.wsdl" />
</proxy>
Ack Service Rs Sequence
<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="ackServiceSearchSeqRs">
<log level="custom">
<property name="Below Response recieved from Ack-WS" value="==================" />
</log>
<log level="full" />
<property xmlns:ns1="http://ack.pepkor.org" xmlns:ns="http://org.apache.synapse/xsd"
xmlns:ax23="http://ack.pepkor.org/xsd" name="product_Colour"
expression="//ns1:productSearchResponse/ns1:return/ax23:product_Colour/text()"
scope="default" type="STRING" />
<log level="custom">
<property xmlns:ns="http://org.apache.synapse/xsd" name="ackRs:Colour : "
expression="$ctx:product_Colour" />
</log>
<property xmlns:ns1="http://ack.pepkor.org" xmlns:ns="http://org.apache.synapse/xsd"
xmlns:ax23="http://ack.pepkor.org/xsd" name="product_ID"
expression="//ns1:productSearchResponse/ns1:return/ax23:product_ID/text()"
scope="default" type="STRING" />
<log level="custom">
<property xmlns:ns="http://org.apache.synapse/xsd" name="ackRs:ID : "
expression="$ctx:product_ID" />
</log>
<property xmlns:ns1="http://ack.pepkor.org" xmlns:ns="http://org.apache.synapse/xsd"
xmlns:ax23="http://ack.pepkor.org/xsd" name="product_Name"
expression="//ns1:productSearchResponse/ns1:return/ax23:product_Name/text()"
scope="default" type="STRING" />
<log level="custom">
<property xmlns:ns="http://org.apache.synapse/xsd" name="ackRs:Name : "
expression="$ctx:product_Name" />
</log>
<property xmlns:ns1="http://ack.pepkor.org" xmlns:ns="http://org.apache.synapse/xsd"
xmlns:ax23="http://ack.pepkor.org/xsd" name="product_Size"
expression="//ns1:productSearchResponse/ns1:return/ax23:product_Size/text()"
scope="default" type="STRING" />
<log level="custom">
<property xmlns:ns="http://org.apache.synapse/xsd" name="ackRs:Size : "
expression="$ctx:product_Size" />
</log>
<property xmlns:ns1="http://ack.pepkor.org" xmlns:ns="http://org.apache.synapse/xsd"
xmlns:ax23="http://ack.pepkor.org/xsd" name="source"
expression="//ns1:productSearchResponse/ns1:return/ax23:source/text()"
scope="default" type="STRING" />
<log level="custom">
<property xmlns:ns="http://org.apache.synapse/xsd" name="ackRs:Source : "
expression="$ctx:source" />
</log>
<property xmlns:ns1="http://ack.pepkor.org" xmlns:ns="http://org.apache.synapse/xsd"
xmlns:ax23="http://ack.pepkor.org/xsd" name="type"
expression="//ns1:productSearchResponse/ns1:return/ax23:type/text()"
scope="default" type="STRING" />
<log level="custom">
<property xmlns:ns="http://org.apache.synapse/xsd" name="ackRs:Type : "
expression="$ctx:type" />
</log>
<payloadFactory media-type="xml">
<format>
<productDetails xmlns:pep="http://za.co.pepkor/product_service/">
<productID>$1</productID>
<productName>$2</productName>
<productSize>$3</productSize>
<productColour>$4</productColour>
<productType>$5</productType>
<sourceID>$6</sourceID>
</productDetails>
</format>
<args>
<arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
expression="$ctx:product_ID" />
<arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
expression="$ctx:product_Name" />
<arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
expression="$ctx:product_Size" />
<arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
expression="$ctx:product_Colour" />
<arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
expression="$ctx:type" />
<arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
expression="$ctx:source" />
</args>
</payloadFactory>
<send />
</sequence>
Shc Service Rs Sequence
<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="shcServiceSearchSeqRs">
<log level="custom">
<property name="Below response recieved from Shc-DS" value="==================" />
</log>
<log level="full" />
<property xmlns:ns1="SHC" xmlns:ns="http://org.apache.synapse/xsd"
name="Product_ID" expression="//ns1:productDetails/ns1:Product_ID/text()"
scope="default" type="STRING" />
<log level="custom">
<property xmlns:ns="http://org.apache.synapse/xsd" name="shcRs: Product_ID : "
expression="$ctx:Product_ID" />
</log>
<property xmlns:ns1="SHC" xmlns:ns="http://org.apache.synapse/xsd"
name="Product_Name" expression="//ns1:productDetails/ns1:Product_Name/text()"
scope="default" type="STRING" />
<log level="custom">
<property xmlns:ns="http://org.apache.synapse/xsd" name="shcRs: Product_Name : "
expression="$ctx:Product_Name" />
</log>
<property xmlns:ns1="SHC" xmlns:ns="http://org.apache.synapse/xsd"
name="Product_Size" expression="//ns1:productDetails/ns1:Product_Size/text()"
scope="default" type="STRING" />
<log level="custom">
<property xmlns:ns="http://org.apache.synapse/xsd" name="shcRs: Product_Size : "
expression="$ctx:Product_Size" />
</log>
<property xmlns:ns1="SHC" xmlns:ns="http://org.apache.synapse/xsd"
name="Product_Colour" expression="//ns1:productDetails/ns1:Product_Colour/text()"
scope="default" type="STRING" />
<log level="custom">
<property xmlns:ns="http://org.apache.synapse/xsd" name="shcRs: Product_Colour : "
expression="$ctx:Product_Colour" />
</log>
<property xmlns:ns1="SHC" xmlns:ns="http://org.apache.synapse/xsd"
name="Product_Type" expression="//ns1:productDetails/ns1:Product_Type/text()"
scope="default" type="STRING" />
<log level="custom">
<property xmlns:ns="http://org.apache.synapse/xsd" name="shcRs: Product_Type : "
expression="$ctx:Product_Type" />
</log>
<property xmlns:ns1="SHC" xmlns:ns="http://org.apache.synapse/xsd"
name="Source" expression="//ns1:productDetails/ns1:Source/text()"
scope="default" type="STRING" />
<log level="custom">
<property xmlns:ns="http://org.apache.synapse/xsd" name="shcRs: Source : "
expression="$ctx:Source" />
</log>
<payloadFactory media-type="xml">
<format>
<productDetails xmlns="">
<productID>$1</productID>
<productName>$2</productName>
<productSize>$3</productSize>
<productColour>$4</productColour>
<productType>$5</productType>
<sourceID>$6</sourceID>
</productDetails>
</format>
<args>
<arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
expression="$ctx:Product_ID" />
<arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
expression="$ctx:Product_Name" />
<arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
expression="$ctx:Product_Size" />
<arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
expression="$ctx:Product_Colour" />
<arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
expression="$ctx:Product_Type" />
<arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml"
expression="$ctx:Source" />
</args>
</payloadFactory>
<send />
</sequence>
SOAP Rs
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<productDetails>
<productID>214562</productID>
<productName>NIKE_SHIRTS</productName>
<productSize>7</productSize>
<productColour>RED</productColour>
<productType>SHIRT</productType>
<sourceID>SHC</sourceID>
</productDetails>
</soapenv:Body>
</soapenv:Envelope>
WSO2 Carbon Log
https : // docs. google. com/document/d/12At0zir99H9cOo9hzNrgG33r52PHF0W32XLyBT6dzUQ/edit? usp=sharing
Edit
My AggHandlerSequence :
<sequence xmlns="http://ws.apache.org/ns/synapse">
<log level="custom">
<property name="pocSearchRsHandlerSeq reached" value="++++++++++++++=========Aggregating now========+++++++++++++++++=="></property>
</log>
<aggregate>
<completeCondition>
<messageCount min="-1" max="-1"></messageCount>
</completeCondition>
<onComplete xmlns:ns="http://org.apache.synapse/xsd" xmlns:prod="http://za.co.pepkor/product_service/" expression="//prod:productSearchResp/productDetails">
<log level="custom" separator=",">
<property name="::::" value="======================= Sending Back the Aggregated Responses. ==============="></property>
</log>
<respond></respond>
</onComplete>
</aggregate>
</sequence>
And one of my Rs Seq
<sequence xmlns="http://ws.apache.org/ns/synapse">
:
:
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:prod="http://za.co.pepkor/product_service/">
<soapenv:Body>
<prod:productSearchResp>
<productDetails xmlns="">
<productID>$1</productID>
<productName>$2</productName>
<productSize>$3</productSize>
<productColour>$4</productColour>
<productType>$5</productType>
<sourceID>$6</sourceID>
</productDetails>
</prod:productSearchResp>
</soapenv:Body>
</soapenv:Envelope>
:
:
<sequence key="conf:/pocSearchRsHandlerSeq"></sequence>
:
:
But am getting this Rs in soap
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<productDetails>
<productID>2145627</productID>
<productName>NIKE_SHIRTS</productName>
<productSize>7</productSize>
<productColour>RED</productColour>
<productType>SHIRT</productType>
<sourceID>ACK</sourceID>
</productDetails>
<productDetails>
<productID>214562</productID>
<productName>NIKE_SHIRTS</productName>
<productSize>7</productSize>
<productColour>RED</productColour>
<productType>SHIRT</productType>
<sourceID>SHC</sourceID>
</productDetails>
</soapenv:Body>
</soapenv:Envelope>
I however want a response similar to the Payload factory in the Rs seq , have tried playing with the corrolateOn expression. Can I store these aggregated fields as properties and use them in a payload factory or how do I map the Agg responses to ?
Final edit
Got it perfect here's a Rs seq payload:(this will be recieved by agg handler)
<productDetails xmlns="">
<productID>$1</productID>
<productName>$2</productName>
<productSize>$3</productSize>
<productColour>$4</productColour>
<productType>$5</productType>
<sourceID>$6</sourceID>
</productDetails>
And my full agg handler :
<sequence xmlns="http://ws.apache.org/ns/synapse">
<log level="custom">
<property name="pocSearchRsHandlerSeq reached" value="++++++++++++++=========Aggregating now========+++++++++++++++++=="></property>
</log>
<aggregate>
<completeCondition>
<messageCount min="-1" max="-1"></messageCount>
</completeCondition>
<onComplete xmlns:ns="http://org.apache.synapse/xsd" expression="//productDetails">
<log level="custom" separator=",">
<property name="::::" value="======================= Formatting the Aggregated Responses. ==============="></property>
</log>
<log level="full"></log>
<payloadFactory media-type="xml">
<format>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:prod="http://za.co.pepkor/product_service/">
<soapenv:Body>
<prod:productSearchResp> $1 </prod:productSearchResp>
</soapenv:Body>
</soapenv:Envelope>
</format>
<args>
<arg expression="//productDetails" evaluator="xml"></arg>
</args>
</payloadFactory>
<respond></respond>
</onComplete>
</aggregate>
</sequence>
If you want to use aggregate mediator, the 2 responses must be go to the same sequence in which you use this mediator
In your proxy inSequence, you use clone and call "ackServiceSearchSeqRq" and "shcServiceSearchSeqRq" as you already do
In each of theses request seq, you format your request according to the service you want to call and then use send mediator from one of these ways :
1st Option : <send> <endpoint key="xxx"> </send> : the 2 responses from your 2 services will go to your proxy's outSequence
2nd Option : <send receive="MyAggregateSequence"> <endpoint key="xxx"> </send> : the 2 responses from your 2 services will go to "MyAggregateSequence"
In your proxy's outSequence or in "MyAggregateSequence", depending on the option you have chosen, you use filter or switch mediator to determine if it is a response from ackService or from shcService and decide which transformation to apply (pay attention to the productDetails node you create with payloadFactory, if there is no namespace then specify xmlns="" each time : this is not the case in your samples) before calling aggregate mediator. Inside aggregate/onComplete, you can use send mediator with no endpoint to send back your aggregated message to the proxy's caller.
In your case, there is 2 <send/>, one in each of your 2 Rs sequence : the 1st one is sent to the proxy's caller and the 2nd one does nothing (the ESB must says than you try to respond 2 times).
When using the clone mediator and you want to collect the response of the two messages, you must set and id on the clone mediator and using the same id in the aggregator mediator.
< clone id="XXX">
< aggregate id="XXX">
This way the aggregator knows to which calls it needs to wait for.
The Endpoint_BPS_CreateCaseService/UpdateCaseService endpoints below both point to one-way BPEL services running on WSO2 BPS. WSO2 BPS returns a HTTP 202 accepted message instantly when they are invoked.
The client application that I am using will throw a fault if it does not get a valid SOAP envelope as a response so I'm going to use a proxy service in ESB to wrap around the BPEL process.
How do I use a WSO2 ESB proxy service to forward a SOAP envelope to Endpoint_BPS_* below and then return a SOAP envelope response to my client app?
I also want to execute the faultSequence "ProcessFault" if either endpoint is unavailable or times out. I previously used the OUT_ONLY to get around the response issue above but it means I can't detect endpoint problems. Unless it is possible to do both somehow?
Another thing I've tried is cloning the message but this was a bit messy.
Any help greatly appreciated
<proxy xmlns="http://ws.apache.org/ns/synapse" name="BPSProxyService" transports="https,http" statistics="disable" trace="enable" startOnLoad="true">
<target faultSequence="ProcessFault">
<inSequence>
<log level="full">
<property name="MESSAGE" value="BEGIN BPSProxyService" />
</log>
<switch source="//*[local-name()='Operation']">
<case regex="create">
<send>
<endpoint key="Endpoint_BPS_CreateCaseService" />
</send>
</case>
<case regex="update">
<send>
<endpoint key="Endpoint_BPS_UpdateCaseService" />
</send>
</case>
</switch>
</inSequence>
<outSequence>
<property name="HTTP_SC" value="200" scope="axis2" />
<class name="esb.mediators.InjectSOAPEnvelope" />
<log level="full">
<property name="MESSAGE" value="END BPSProxyService" />
</log>
<send />
<drop />
</outSequence>
</target>
<publishWSDL key="common/bpsproxyservice/bpsproxyservice.wsdl">
<resource location="schema.xsd" key="common/schema_v2.xsd" />
</publishWSDL>
</proxy>
When you receive a 'HTTP/1.1 202 Accepted' response from your backend like BPS in the outSequence of your Proxy Service, then you need the <property name="SC_ACCEPTED" value="false" scope="axis2"/> statement to modify the '202'-response into something else.
Example:
<property name="SC_ACCEPTED" value="false" scope="axis2"/>
<property name="HTTP_SC" value="200" scope="axis2"/>
<payloadFactory media-type="xml">
<format>
<response>
<result>OK</result>
</response>
</format>
<args/>
</payloadFactory>
<send/>
The response is transformed into 'HTTP/1.1 200 OK' with a response message.
Add the "FORCE_SC_ACCEPTED" parameter with the "OUT_ONLY" in the inSequence of the proxy service as follows.
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2" type="STRING"/>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
For more information use the following article:
http://mohanadarshan.wordpress.com/2013/05/05/out_only-scenario-in-proxy-service-wso2-esb/