Newbie on WSO2 ESB, we start using it as our central point as ESB but we are facing a real issue by doing a simple case :/
Here is the api I wrote (based on that simple) to show you my issue even if our usecase is different.
Users
<?xml version="1.0" encoding="UTF-8" ?>
<api context="/services/users" name="ListUsersAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" protocol="http" url-mapping="/*">
<inSequence>
<payloadFactory media-type="json">
<format>{ "persons":{ "person":[ { "Id":"1", "givenName":"ajith", "lastName":"vitharana", "age":"25", "contactInfos":[ { "InfoId":"1", "department":"1", "contactType":"email", "value":"ajith#abc.org" }, { "InfoId":"2", "department":"1", "contactType":"mobile",
"value":"111111111" }, { "InfoId":"3", "department":"1", "contactType":"home", "value":"Magic Dr,USA" } ] }, { "Id":"2", "givenName":"shammi", "lastName":"jagasingha", "age":"30", "contactInfos":[ { "InfoId":"1", "department":"1", "contactType":"email",
"value":"shammi#abc.org" }, { "InfoId":"2", "department":"1", "contactType":"mobile", "value":"2222222222" }, { "InfoId":"3", "department":"1", "contactType":"home", "value":"Magic Dr,USA" } ] } ] }}</format>
<args/>
</payloadFactory>
<property action="remove" name="NO_ENTITY_BODY" scope="axis2" />
<property name="messageType" scope="axis2" type="STRING" value="application/json" />
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
Roles
<?xml version="1.0" encoding="UTF-8" ?>
<api context="/services/roles" name="UserRolesAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" protocol="http" uri-template="/{personid}">
<inSequence>
<filter regex="1" source="get-property('uri.var.personid')">
<then>
<payloadFactory media-type="json">
<format>{ "Id":1, "roles":[ { "roleId":1, "personKey":1, "role":"Deverloper" }, { "roleId":2, "personKey":1, "role":"Engineer" } ]}</format>
<args/>
</payloadFactory>
<property action="remove" name="NO_ENTITY_BODY" scope="axis2" />
<property name="messageType" scope="axis2" type="STRING" value="application/json" />
<respond/>
</then>
<else/>
</filter>
<filter regex="2" source="get-property('uri.var.personid')">
<then>
<payloadFactory media-type="json">
<format>{"personId": 2,"roles": [{ "personRoleId": 1, "personKey": 2, "role": "Manager" },{ "personRoleId": 2, "personKey": 2, "role": "QA" }]}</format>
<args/>
</payloadFactory>
<property action="remove" name="NO_ENTITY_BODY" scope="axis2" />
<property name="messageType" scope="axis2" type="STRING" value="application/json" />
<respond/>
</then>
<else/>
</filter>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
Finally, the main one, calling the first one, then iterating
<?xml version="1.0" encoding="UTF-8" ?>
<api context="/userdetails" name="UserDetailsAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" protocol="http">
<inSequence>
<call>
<endpoint>
<http method="get" trace="disable" uri-template="http://localhost:8280/services/users" />
</endpoint>
</call>
<iterate attachPath="//jsonObject/persons" expression="//jsonObject/persons/person" id="it1" preservePayload="true" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<target>
<sequence>
<property expression="$body/jsonObject/persons/person/Id" name="uri.var.Id" scope="default" type="STRING" xmlns:ns="http://org.apache.synapse/xsd" />
<property expression="$body//jsonObject//person" name="response1" scope="default" type="STRING" xmlns:ns="http://org.apache.synapse/xsd" />
<call>
<endpoint>
<http method="get" trace="disable" uri-template="http://localhost:8280/services/roles/{uri.var.Id}" />
</endpoint>
</call>
<loopback/>
</sequence>
</target>
</iterate>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence>
<sequence key="fault" />
</faultSequence>
</resource>
</api>
Executing the last api (http://localhost:8280/userdetails) is causing the following NPE:
20160408T101619.566 org.apache.synapse.transport.passthru.PassThroughHttpSender.handleException(PassThroughHttpSender.java:609) [PassThroughMessageProcessor-14] PassThroughHttpSender - Failed to submit the response
java.lang.NullPointerException
at org.apache.synapse.transport.passthru.util.SourceResponseFactory.create(SourceResponseFactory.java:64)
at org.apache.synapse.transport.passthru.PassThroughHttpSender.submitResponse(PassThroughHttpSender.java:462)
at org.apache.synapse.transport.passthru.PassThroughHttpSender.invoke(PassThroughHttpSender.java:267)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:212)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:444)
at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:102)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:81)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:48)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:149)
at org.apache.synapse.rest.Resource.process(Resource.java:297)
at org.apache.synapse.rest.API.process(API.java:335)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:97)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:52)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:266)
at org.apache.synapse.mediators.builtin.LoopBackMediator.mediate(LoopBackMediator.java:55)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:81)
at org.apache.synapse.mediators.eip.splitter.IterateMediator.mediate(IterateMediator.java:241)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:267)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:679)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:244)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:529)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:172)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:251)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
20160408T101619.576 org.apache.synapse.core.axis2.Axis2Sender.handleException(Axis2Sender.java:246) [PassThroughMessageProcessor-14] Axis2Sender - Accept:*/*,Accept-Encoding:gzip, deflate, sdch,Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4,Cache-Control:no-cache,Content-Type:application/json; charset=UTF-8,Host:localhost:8280,Postman-Token:3bfb96b7-0c31-964e-8c37-3b5dbd222efe,<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><jsonObject><Id>1</Id><roles><roleId>1</roleId><personKey>1</personKey><role>Deverloper</role></roles><roles><roleId>2</roleId><personKey>1</personKey><role>Engineer</role></roles></jsonObject></soapenv:Body></soapenv:Envelope> Unexpected error sending message back
org.apache.axis2.AxisFault: Failed to submit the response
at org.apache.synapse.transport.passthru.PassThroughHttpSender.handleException(PassThroughHttpSender.java:610)
at org.apache.synapse.transport.passthru.PassThroughHttpSender.invoke(PassThroughHttpSender.java:269)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:212)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:444)
at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:102)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:81)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:48)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:149)
at org.apache.synapse.rest.Resource.process(Resource.java:297)
at org.apache.synapse.rest.API.process(API.java:335)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:97)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:52)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:266)
at org.apache.synapse.mediators.builtin.LoopBackMediator.mediate(LoopBackMediator.java:55)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:81)
at org.apache.synapse.mediators.eip.splitter.IterateMediator.mediate(IterateMediator.java:241)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:267)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:679)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:244)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:529)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:172)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:251)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at org.apache.synapse.transport.passthru.util.SourceResponseFactory.create(SourceResponseFactory.java:64)
at org.apache.synapse.transport.passthru.PassThroughHttpSender.submitResponse(PassThroughHttpSender.java:462)
at org.apache.synapse.transport.passthru.PassThroughHttpSender.invoke(PassThroughHttpSender.java:267)
... 26 more
I'm afraid, this is the same issue than here (but not sure).
Would you please help me quickly to avoid before we decide to give wso2 away ?
The better would be to have the third part (userdetails) fixed by an answer.
Thank a lot !
In this case your loopback is inside the iterate mediator and that is calling outSequence each time you iterate.
If you move your loopback mediator out of the iterate as shown below, this should send the last response from the iterate to the client. If you want to aggregate your responses from the iteration, you should use aggregate mediator[1].
[1] https://docs.wso2.com/display/ESB490/Aggregate+Mediator
Updated
Unfortunately the above solution does not work, because each time an iteration completes, the flow still continues, so even if we have a loopback outside the iterate, we will be calling the outSequence multiple times. We will have to use an aggregate to be able to use the complete condition to trigger the outSequence once. Please have a look at the below configuration.
<api xmlns="http://ws.apache.org/ns/synapse" name="UserDetailsAPI" context="/userdetails">
<resource methods="GET">
<inSequence>
<call>
<endpoint>
<http trace="disable" method="GET" uri-template="http://localhost:8280/services/users"/>
</endpoint>
</call>
<iterate xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" id="it1" preservePayload="true" attachPath="//jsonObject/persons" expression="//jsonObject/persons/person">
<target>
<sequence>
<property xmlns:ns="http://org.apache.synapse/xsd" name="uri.var.Id" expression="$body/jsonObject/persons/person/Id" scope="default" type="STRING"/>
<property xmlns:ns="http://org.apache.synapse/xsd" name="response1" expression="$body//jsonObject//person" scope="default" type="STRING"/>
<call>
<endpoint>
<http trace="disable" method="GET" uri-template="http://localhost:8280/services/roles/{uri.var.Id}"/>
</endpoint>
</call>
</sequence>
</target>
</iterate>
<aggregate id="it1">
<completeCondition>
<messageCount min="-1" max="-1"/>
</completeCondition>
<onComplete expression="//jsonObject">
<loopback/>
</onComplete>
</aggregate>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence>
<sequence key="fault"/>
</faultSequence>
</resource>
</api>
Related
When i try to call a remote web-service using a dynamic uri-template in send mediator, i receive this error.
The url of the resource to call is : https://ec.europa.eu/esco/api/resource/skill?uri=http://data.europa.eu/esco/skill/a59708e3-e654-4e37-8b8a-741c3b756eee&language=it
For this purpose i use below in-sequence and out-sequence:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="EscoInSequence" xmlns="http://ws.apache.org/ns/synapse">
<property expression="$url:resource" name="resource" scope="default"
type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
<property expression="$url:uri" name="uri"
scope="default" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
<property expression="$url:language" name="language" scope="default"
type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
<property
expression="concat('https://ec.europa.eu/esco/api/resource/',$ctx:resource,'?uri=',$ctx:uri,'&language=',$ctx:language)"
name="UrlToEsco" scope="default" type="STRING" xmlns:ns="http://org.apache.synapse/xsd"/>
<payloadFactory media-type="text">
<format>$1</format>
<args>
<arg evaluator="xml" expression="$ctx:UrlToEsco"
literal="false" xmlns:ns="http://org.apache.synapse/xsd"/>
</args>
</payloadFactory>
<send>
<endpoint>
<http method="GET" uri-template="{UrlToEsco}"/>
</endpoint>
</send>
<enrich>
<source clone="true" type="body"/>
<target action="child" property="rispostaEsco" type="property"/>
</enrich>
<loopback/>
</sequence>
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="EscoOutSequence" xmlns="http://ws.apache.org/ns/synapse">
<send/>
</sequence>
When i try to call my api using a static uri ( https://ec.europa.eu/esco/api/resource/skill?uri=http://data.europa.eu/esco/skill/a59708e3-e654-4e37-8b8a-741c3b756eee&language=it ) i haven't problem, but when i use UrlToEsco property i obtain this error :
TID[-1234] [EI] [2019-09-03 12:31:53,029] ERROR
{org.apache.synapse.core.axis2.Axis2Sender} - Unexpected error during
sending message out
org.apache.axis2.description.ClientUtils.inferOutTransport(ClientUtils.java:86)
org.apache.synapse.core.axis2.DynamicAxisOperation$DynamicOperationClient.executeImpl(DynamicAxisOperation.java:116)
org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:603)
org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:85)
org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:547)
org.apache.synapse.endpoints.AbstractEndpoint.send(AbstractEndpoint.java:384)
org.apache.synapse.endpoints.HTTPEndpoint.send(HTTPEndpoint.java:85)
org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:123)
org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:108)
org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:70)
org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
org.apache.synapse.rest.Resource.process(Resource.java:364)
org.apache.synapse.rest.API.process(API.java:399)
org.apache.synapse.rest.RESTRequestHandler.apiProcess(RESTRequestHandler.java:123)
org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:101)
org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:69)
org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:303)
org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:92)
org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:337)
org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:158)
org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
java.lang.Thread.run(Thread.java:745)
Uri templates variables should be named as follows uri.var.[parameterName] so for example uri.var.UrlToEsco.
Try renameing your property
<property expression="concat('https://ec.europa.eu/esco/api/resource/',$ctx:resource,'?
uri=',$ctx:uri,'&language=',$ctx:language)"
name="uri.var.UrlToEsco" scope="default" type="STRING"
xmlns:ns="http://org.apache.synapse/xsd"/>
And using it like so:
<send>
<endpoint>
<http method="GET" uri-template="{uri.var.UrlToEsco}"/>
</endpoint>
</send>
I'm using wso2ei 6.0.0 and I have a simple task - send specific xml message via POST to the endpoint.
I have API configured like this:
<api xmlns="http://ws.apache.org/ns/synapse" name="glisTest" context="/glisTest">
<resource methods="GET" uri-template="/{sampleid}">
<inSequence>
<property name="PRESERVE_WS_ADDRESSING" value="false"/>
<payloadFactory media-type="xml">
<format>
<register />
</format>
</payloadFactory>
<log level="full"/>
<property name="messageType" value="application/xml" scope="axis2" type="STRING"/>
<property name="HTTP_METHOD" value="post" scope="axis2" type="STRING"/>
<send>
<endpoint>
<address uri="https://localhost/manager" encoding="UTF-8" format="pox"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="full"/>
<send/>
</outSequence>
</resource>
</api>
But service is expected
<?xml version="1.0" encoding="UTF-8" ?>
to be inserted at the beginning and wso2 do not do it (I just added debug logging for org.apache.synapse.transport.http.wire and I see it simple send
<register/>
As result, it does not recognize message as an xml and returm me error.
Question - how to tell synapse to add this special xml header to the message?
I am doing iteration over the DSS response, But not working as expected
Below is the payload and call for DSS:
<payloadFactory media-type="xml">
<format>
<p:getNominaIDDetails xmlns:p="http://ws.wso2.org/dataservice">
<xs:column1 xmlns:xs="http://ws.wso2.org/dataservice">$1</xs:column1>
<xs:column2 xmlns:xs="http://ws.wso2.org/dataservice">$2</xs:column2>
<xs:column3 xmlns:xs="http://ws.wso2.org/dataservice">$3</xs:column3>
<xs:column4 xmlns:xs="http://ws.wso2.org/dataservice">$4</xs:column4>
</p:getNominaIDDetails>
</format>
<args>
<arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('column1')" evaluator="xml"></arg>
<arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('column2')" evaluator="xml"></arg>
<arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('column3')" evaluator="xml"></arg>
<arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('column4')" evaluator="xml"></arg>
</args>
</payloadFactory>
<header name="Action" scope="default" value="urn:xxxxxxx"></header>
<call>
<endpoint key="gov:/dss/endpoint"></endpoint>
</call>
<filter xmlns:ns="http://org.apache.synapse/xsd"
xmlns:ds="http://ws.wso2.org/dataservice"
xpath="get-property('db_count')>0">
<then>
<iterate id="xxx"
preservePayload="true"
attachPath="//ds:xxxx"
expression="//ds:xxx/ds:xxx">
<target sequence="My_seq">
</target>
</iterate>
</then>
<else>
<drop/>
</else>
</filter>
Response from the dss is:
<response xmlns="http://ws.wso2.org/dataservice">
<id>
<column1>234</column1>
<column1>4455</column1>
<column1>567778</column1>
</id>
<id>
<column1>546</column1>
<column1>56866</column1>
<column1>464453</column1>
</id>
<id>
<column1>546</column1>
<column1>56866</column1>
<column1>464453</column1>
</id>
</response>
With the above response completing with first iteration and remaining all the messages expiring after global timeout.Below are the logs after first iteration:
{org.apache.synapse.mediators.builtin.LogMediator}
TID: [0] [ESB] [2016-09-04 06:26:13,471] WARN {org.apache.synapse.core.axis2.SynapseCallbackReceiver} - Synapse received a response for the request with message Id : urn:uuid:c62d7dae-5290-49d1-b1bd-b5d2dcba7e04 But a callback is not registered (anymore) to process this response {org.apache.synapse.core.axis2.SynapseCallbackReceiver}
TID: [0] [ESB] [2016-09-04 06:26:42,144] WARN {org.apache.synapse.core.axis2.TimeoutHandler} - Expiring message ID : urn:uuid:36df3897-73be-4bc3-a434-aaab618c7ce3; dropping message after global timeout of : 180 seconds {org.apache.synapse.core.axis2.TimeoutHandler}
TID: [0] [ESB] [2016-09-04 06:26:42,145] WARN {org.apache.synapse.core.axis2.TimeoutHandler} - Expiring message ID : urn:uuid:d8ec8998-95c6-4d70-9e33-c11bda271e90; dropping message after global timeout of : 180 seconds {org.apache.synapse.core.axis2.TimeoutHandler}
Note: inside iterator doing following operations(sequence="My_seq")
perfoming the Bank call-->DSS call-->SAP call using call meditor
<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="My_seq" >
<property xmlns:ns="http://org.apache.synapse/xsd" xmlns:ds="http://ws.wso2.org/dataservice" name="id" expression="//ds:dss_response/ds:Id" scope="default" type="STRING"/>
<payloadFactory media-type="xml">
<format>
<h:opertion xmlns:h="http://ws.wso2.org/xxxxxx">
<h2h:id>$1</h2h:id>
</h:opertion>
</format>
<args>
<arg xmlns:ns="http://org.apache.synapse/xsd" evaluator="xml" expression="get-property('id')"/>
</args>
</payloadFactory>
<property xmlns:ns="http://org.apache.synapse/xsd" name="Authorization" expression="fn:concat('Basic ', base64Encode('xxxxx:xxxxxxxx'))" scope="transport" type="STRING"/>
<property name="ContentType" value="application/soap+xml" scope="axis2" type="STRING"/>
<property name="messageType" value="application/soap+xml" scope="axis2" type="STRING"/>
<call>
<endpoint key="gov:/endpoint"/>
</call>
<sequence key="next_sequence_to_be_DSS_then_SAP"/>
</sequence>
I believe this should suit your requirement. Here I'm checking status of incoming responses and send OK to client only if every request was successful.
<api xmlns="http://ws.apache.org/ns/synapse" name="MyAPI" context="/myapi">
<resource methods="POST GET" url-mapping="/">
<inSequence>
<call blocking="true">
<endpoint>
<http uri-template="http://www.mocky.io/v2/57cd6f422d00000101b15868"/>
</endpoint>
</call>
<property name="Staus" value="OK" type="STRING"/>
<iterate xmlns:ds="http://ws.wso2.org/dataservice" id="xxx" preservePayload="true" expression="//ds:response/ds:id">
<target>
<sequence>
<send>
<endpoint>
<http uri-template="http://www.mocky.io/v2/57cd70c22d00002401b1586c"/>
</endpoint>
</send>
</sequence>
</target>
</iterate>
</inSequence>
<outSequence>
<filter source="$axis2:HTTP_SC" regex="200">
<then/>
<else>
<property name="Staus" value="NOT OK" type="STRING"/>
</else>
</filter>
<aggregate id="xxx">
<completeCondition>
<messageCount/>
</completeCondition>
<onComplete xmlns:ds="http://ws.wso2.org/dataservice" expression="/">
<log level="custom">
<property name="Final Staus" expression="$ctx:Staus"/>
</log>
<payloadFactory media-type="xml">
<format>
<status>$1</status>
</format>
<args>
<arg evaluator="xml" expression="$ctx:Status"/>
</args>
</payloadFactory>
<send/>
</onComplete>
</aggregate>
</outSequence>
</resource>
</api>
I have a registered onError sequence.
In version 4.8.1 SOAP envelop is available in onError sequence
while in 4.9.0 it is not.
in order to access SOAP message content in 4.9.0 after error (in onError sequence) I always have to copy it to some temp variable initially. it is very inconvenient.
could it be a bug or is it a new "feature" of 4.9.0?
this is my fault sequence. if i remove enrich mediator envelope comes empty from the sequence with an error. Without enrich mediator message contains empty soap envelope. It can be seen in the output of the log mediator and in the message stored in RabbitMQ backend. Actually, it is onError sequence of XXXXNotifySendSequence sequence (I added them both for the reference).
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="XXXXNotifyErrorSequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<log level="full">
<property name="mssg" expression="get-property('mssg')"/>
<property name="retry_count" expression="get-property('retry_count')"/>
</log>
<filter xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xpath="get-property('mssg')">
<then>
<enrich>
<source clone="true" property="mssg" type="property"/>
<target type="envelope"/>
</enrich>
<property name="mssg" action="remove"/>
</then>
<else/>
</filter>
<filter xmlns:ns="http://org.apache.synapse/xsd" xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:ns3="http://org.apache.synapse/xsd" xpath="get-property('retry_count')">
<then>
<property name="retry_count" expression="number(get-property('retry_count'))+1" scope="default" type="STRING"/>
<filter xpath="get-property('retry_count') > 5">
<then>
<log>
<property name="Dropping--Count" expression="get-property('retry_count')"/>
</log>
<drop/>
</then>
<else>
<sequence key="XXXXNotifySendSequence"/>
</else>
</filter>
</then>
<else>
<property name="retry_count" value="1" scope="default" type="STRING"/>
<clone continueParent="true">
<target>
<sequence>
<makefault version="soap11">
<code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:VersionMismatch"/>
<reason expression="get-property('ERROR_MESSAGE')"/>
</makefault>
<send/>
</sequence>
</target>
</clone>
</else>
</filter>
<clone>
<target>
<sequence>
<log level="custom">
<property name="STORE" value="store the message"/>
</log>
<store messageStore="XXXXRabbitMQNative"/>
</sequence>
</target>
</clone>
</sequence>
this is the sequence calling onError sequence
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="XXXXNotifySendSequence"
onError="XXXXNotifyErrorSequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<log level="full">
<property name="XXXX" value="request start"/>
</log>
<enrich>
<source clone="true" type="envelope"/>
<target property="mssg" type="property"/>
</enrich>
<property name="DISABLE_CHUNKING" scope="axis2" type="STRING" value="true"/>
<call>
<endpoint key="HTTPEndpoint"/>
</call>
<log level="full">
<property name="XXXX" value="request end"/>
</log>
</sequence>
I am not much sure why you written fault sequence in that way. but when i change like bellow its working. no need to enrich and assign to other property
Sequence:(same as yours - untouched)
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="XXXXNotifySendSequence"
onError="XXXXNotifyErrorSequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<log level="full">
<property name="XXXX" value="request start"/>
</log>
<enrich>
<source clone="true" type="envelope"/>
<target action="replace" property="mssg" type="property"/>
</enrich>
<property name="DISABLE_CHUNKING" scope="axis2" type="STRING" value="true"/>
<call>
<endpoint key="HTTPEndpoint"/>
</call>
<log level="full">
<property name="XXXX" value="request end"/>
</log>
</sequence>
fault sequence:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="XXXXNotifyErrorSequence" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<log>
<property expression="get-property('ERROR_CODE')"
name="========error-code=========" xmlns:ns="http://org.apache.synapse/xsd"/>
<property expression="get-property('ERROR_MESSAGE')"
name="========error-message=========" xmlns:ns="http://org.apache.synapse/xsd"/>
</log>
<makefault version="soap11">
<code value="soap11Env:VersionMismatch" xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/"/>
<reason expression="get-property('ERROR_MESSAGE')" xmlns:ns="http://org.apache.synapse/xsd"/>
<role>sample</role>
<detail>sample detail</detail>
</makefault>
<send/>
</sequence>
proxy: to call sequence
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="samplecall"
transports="http,https"
statistics="disable"
trace="disable"
startOnLoad="true">
<target inSequence="XXXXNotifySendSequence"/>
<description/>
</proxy>
response: (since end point is not defined)
<soapenv:Fault xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<faultcode xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/">soap11Env:VersionMismatch</faultcode>
<faultstring>Couldn't find the endpoint with the key : HTTPEndpoint</faultstring>
<faultactor>sample</faultactor>
<detail>sample detail</detail>
</soapenv:Fault>
in log:
2015-11-08 17:19:55,250] INFO - LogMediator To: /services/samplecall.samplecallHttpSoap11Endpoint, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:106d763f-cdc1-43d2-98a9-63d22d17eb81, Direction: request, XXXX = request start, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body/></soapenv:Envelope>
[2015-11-08 17:19:55,252] INFO - LogMediator To: /services/samplecall.samplecallHttpSoap11Endpoint, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:106d763f-cdc1-43d2-98a9-63d22d17eb81, Direction: request, ========error-code========= = 305100, ========error-message========= = Couldn't find the endpoint with the key : HTTPEndpoint
I am working on sample application in WSO2 esb
which connects to Oracle Database and return the response of a query. Below mentioned is my service. Issue I am facing is I am not getting the response back after execution of service.However I am able to see the value returned as a query response, but not able to render it in response document.
Can anybody suggest, what I am missing?
DB credentials fields have been hashed.
Proxy :
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="getEmployeeDetails"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="OUT_ONLY" value="true" scope="default" type="BOOLEAN"/>
<log level="full" category="DEBUG"/>
<dblookup>
<connection>
<pool>
<password>****</password>
<user>****</user>
<url>****</url>
<driver>oracle.jdbc.xa.client.OracleXADataSource</driver>
</pool>
</connection>
<statement>
<sql>select firstname from employee where lastname = 'pawar'</sql>
<result name="firstname" column="firstname"/>
</statement>
</dblookup>
<log level="custom">
<property name="firstname" expression="get-property('firstname')"/>
</log>
<payloadFactory media-type="xml">
<format>
<GetEmployeeDetailsResponse xmlns="">
<out>$1</out>
</GetEmployeeDetailsResponse>
</format>
<args>
<arg evaluator="xml" expression="get-property('firstname')"/>
</args>
</payloadFactory>
</inSequence>
<outSequence>
<log level="full" category="DEBUG"/>
</outSequence>
</target>
<publishWSDL uri="file:/development/data/wso2/wsdl/Employee.wsdl"/>
<description/>
</proxy>
You have to send back the message generated by your payloadFactory in your inSequence :
<header name="To" action="remove"/>
<property name="RESPONSE" value="true" scope="default" type="STRING"/>
<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
<send/>
Your mediation is "OUT_ONLY", so, your outSequence will never been executed