Can someone help me to fix this ESB code? - api

Encountered this error message below:
org.apache.commons.httpclient.URIException: Invalid query
at org.apache.commons.httpclient.URI.parseUriReference(URI.java:2049)
at org.apache.commons.httpclient.URI.<init>(URI.java:147)
Here are my exact codes below, encountering an issue when calling
<?xml version="1.0" encoding="UTF-8"?>
<api context="/test_api" name="rest" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" uri-template="/hello?name={namVal}">
<inSequence>
<property name="SYSTEM" expression="$url:name"/>
<property name="uri.var.name" expression="$ctx:SYSTEM"/>
<call blocking="true">
<endpoint key="hello_EP"/>
</call>
<payloadFactory media-type="xml">
.....
</payloadFactory>
<respond />
</inSequence>
<outSequence />
<faultSequence />
</resource>
</api>
Here is my EP for reference
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="hello_EP" xmlns="http://ws.apache.org/ns/synapse">
<address uri="http://xxxxxxxxxx:(port)/spring/hello?name={uri.var.fname}" methods="POST"/>
</endpoint>

Query param in the endpoint is {uri.var.fname} but the property name uri.var.name. Therefore change the property name to uri.var.fname.
This can be directly done by a single property instead of having two properties as below,
<property name="uri.var.fname" expression="$url:name"/>

The issue i posted was already fixed yesterday. To fix the issue i need to change the uri-template to url-mapping.
here is my updated code now:
Endpoint:
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="hello_EP" xmlns="http://ws.apache.org/ns/synapse">
<address uri="http://xxxxxxxxxxxxxxxxxx:12345/SpringRest/"/>
</endpoint>
API code.
<?xml version="1.0" encoding="UTF-8"?>
<api context="/temp_api" name="springRest" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" url-mapping="/hello">
<inSequence>
<!-- URL Parameters -->
<property expression="$url:name" name="SYSTEM" scope="default" type="STRING"/>
<!-- Logs -->
<log level="custom">
<property expression="$ctx:SYSTEM" name="value-system"/>
</log>
<!-- URL param value passed to endpoint param -->
<property expression="$ctx:SYSTEM" name="uri.var.fname" scope="default" type="STRING"/>
<!-- Call endpoint -->
<call blocking="true">
<endpoint key="hello_EP"/>
</call>
<payloadFactory media-type="xml">
..
..
</payloadFactory>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
output:
<body xmlns="http://ws.apache.org/ns/synapse">
{
"id": 1,
"content": "Hello, world!"
}
</body>

Related

WSO2ESB: How to add <?xml into the message sent to POX endpoint

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?

[WSO2 ESB][4.9.0] NPE on iterate when sending back

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>

WSO2 ESB: How to write a file from Base64 with VFS?

I have pretty much the same issue as this person:
WSO2 ESB - writing files out of base64
However, in the answer to that question there was no mention of how to decode the Base64 string in JavaScript and attach it to the payload. That's what I'm interested in.
Thanks in advance,
Strainy
Went with a slightly different approach. I created a utility proxy service to re-download the file and then push it into the file system.
utilty_createFile Proxy Service
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="utility_createFile"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target inSequence="utility_createFile_IN" outSequence="utility_createFile_OUT"/>
<description/>
</proxy>
utility_createFile_IN Sequence
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="utility_createFile_IN" onError="fault" xmlns="http://ws.apache.org/ns/synapse">
<property name="FORCE_SC_ACCEPTED" scope="axis2" value="true"/>
<property expression="//createFile/download_folder"
name="uri.var.download_folder" xmlns:ns="http://org.apache.synapse/xsd"/>
<property expression="//createFile/url" name="uri.var.download_url" xmlns:ns="http://org.apache.synapse/xsd"/>
<script language="js"><![CDATA[var download_url = mc.getProperty('uri.var.download_url');
download_url = decodeURIComponent(download_url);
mc.setProperty('uri.var.download_url', download_url);]]></script>
<send>
<endpoint>
<http method="GET" uri-template="{uri.var.download_url}"/>
</endpoint>
</send>
</sequence>
utility_createFile_OUT Sequence
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="utility_createFile_IN" onError="fault" xmlns="http://ws.apache.org/ns/synapse">
<property name="FORCE_SC_ACCEPTED" scope="axis2" value="true"/>
<property expression="//createFile/download_folder"
name="uri.var.download_folder" xmlns:ns="http://org.apache.synapse/xsd"/>
<property expression="//createFile/url" name="uri.var.download_url" xmlns:ns="http://org.apache.synapse/xsd"/>
<script language="js"><![CDATA[var download_url = mc.getProperty('uri.var.download_url');
download_url = decodeURIComponent(download_url);
mc.setProperty('uri.var.download_url', download_url);]]></script>
<send>
<endpoint>
<http method="GET" uri-template="{uri.var.download_url}"/>
</endpoint>
</send>
</sequence>

wso2esb 4.8.1 and 4.9.0 different behaviour onError

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

Removing SOAP Wrapper From a Message in wso2 ESB

I tried to invoke a web service through WSO2esb.My web service is only accepting a soap message like this.
<?xml version="1.0" encoding="UTF-8"?>
<ns1:Envelope xmlns:ns1="http://www.webserviceX.NET/ConversionRate/Input" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Documents and Settings\RoGulk\Desktop\SPM\Envelope.xsd">
<ns1:Body>
<ns2:ConversionRate xmlns:ns2="http://www.webserviceX.NET/">
<ns2:FromCurrency>USD</ns2:FromCurrency>
<ns2:ToCurrency>USD</ns2:ToCurrency>
</ns2:ConversionRate>
</ns1:Body>
</ns1:Envelope>
But the problem is when I read the input message to the esb, The esb adds a additional wrapper to my meaasage like this
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns1:Envelope xmlns:ns1="http://www.webserviceX.NET/ConversionRate/Input">
<ns1:Body>
<ns2:ConversionRate xmlns:ns2="http://www.webserviceX.NET/">
<ns2:FromCurrency>INR</ns2:FromCurrency>
<ns2:ToCurrency>NAD</ns2:ToCurrency>
</ns2:ConversionRate>
</ns1:Body>
</ns1:Envelope>
</soapenv:Body>
</soapenv:Envelope>
I think it can be done by using the 'application/XML' message formatter before I call to my endpoint.But the problem is I don't know how to invoke the 'application/XML' message formatter and where to use it.**
Guys please help me, Thanks
EDITED
I thought that adding my proxy service configuration will be helpful.
In this I am not using default out sequance. Instead of that I am using sequance called "currencyFileWriter" which is responsible for writing a file to a output directory.
This is my proxy service
<proxy xmlns="http://ws.apache.org/ns/synapse" name="CurrencyProxy" transports="https,http,vfs" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<property name="messageType" value="application/xml" scope="default" type="STRING"/>
<property name="ContentType" value="application/xml" scope="default"/>
<log level="custom">
<property name="MessageType" expression="$axis2:ContentType"/>
</log>
<log level="full"/>
<log level="custom">
<property name="insequance" value="================================Forwerded to out File writer sequance====================="/>
</log>
<send receive="currencyFileWriter" buildmessage="true">
<endpoint key="CurrencyConverter"/>
</send>
<log level="custom">
<property name="After" value="============================AFTER SEND================"/>
</log>
<log level="full"/>
</inSequence>
</target>
<parameter name="transport.PollInterval">5</parameter>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.FileURI">file:///C:/test/Orginal1/</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file:///C:/test/Pass1/</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file:///C:/test/Failures1/</parameter>
<parameter name="transport.vfs.FileNamePattern">currencytest.xml</parameter>
<parameter name="transport.vfs.ContentType">application/xml</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<description></description>
</proxy>
And tihs is my CurrencyFilewriter sequance
<sequence xmlns="http://ws.apache.org/ns/synapse" name="currencyFileWriter">
<log level="custom">
<property name="sequance" value="=====================RECIVED TO CURRENCYFILEWRITER=========================="/>
</log>
<log level="full"/>
<property name="transport.vfs.ReplyFileName" value="result.xml" scope="default" type="STRING"/>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<send>
<endpoint>
<address uri="vfs:file:///C:/test/Out1"/>
</endpoint>
</send>
</sequence>
I used the following configuration and I got the following results inside of the VFS folder.
Here's what I've done:
Endpoint Configuration:
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="CurrencyConverter">
<address uri="http://www.webservicex.net/CurrencyConvertor.asmx"></address>
</endpoint>
Sequence Configuration:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="currencyFileWriter">
<log level="custom">
<property name="sequance" value="=====================RECIVED TO CURRENCYFILEWRITER=========================="/>
</log>
<log level="full"/>
<property name="transport.vfs.ReplyFileName" value="result.xml" scope="default" type="STRING"/>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<send>
<endpoint>
<address uri="vfs:file:///home/ravi/esb/wso2esb-4.5.1/vfs-temp/Out1"/>
</endpoint>
</send>
</sequence>
Proxy Configuration:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="CurrencyProxy" transports="https,http,vfs" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log level="custom">
<property name="insequance" value="================================Forwerded to out File writer sequance====================="/>
</log>
<send>
<endpoint key="CurrencyConverter"/>
</send>
<log level="custom">
<property name="After" value="============================AFTER SEND================"/>
</log>
<log level="full"/>
</inSequence>
<outSequence>
<sequence key="currencyFileWriter"/>
</outSequence>
</target>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.PollInterval">5</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file:///home/ravi/esb/wso2esb-4.5.1/vfs-temp/Pass1/</parameter>
<parameter name="transport.vfs.FileURI">file:///home/ravi/esb/wso2esb-4.5.1/vfs-temp/Orginal1/</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file:///home/ravi/esb/wso2esb-4.5.1/vfs-temp/Failures1/</parameter>
<parameter name="transport.vfs.FileNamePattern">currencytest.xml</parameter>
<parameter name="transport.vfs.ContentType">application/xml</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<description></description>
</proxy>
This is what is passed from the client (SOAP UI in my case) to the ESB - I've used SOAP 1.2 here by pointing the namespace ns1 to http://www.w3.org/2003/05/soap-envelope:
<?xml version="1.0" encoding="UTF-8"?>
<ns1:Envelope xmlns:ns1="http://www.w3.org/2003/05/soap-envelope" xmlns:ns2="http://www.webserviceX.NET/ConversionRate/Input">
<ns1:Body>
<ns2:ConversionRate xmlns:ns2="http://www.webserviceX.NET/">
<ns2:FromCurrency>USD</ns2:FromCurrency>
<ns2:ToCurrency>LKR</ns2:ToCurrency>
</ns2:ConversionRate>
</ns1:Body>
</ns1:Envelope>
This is what the ESB sends to the backend service:
POST /CurrencyConvertor.asmx?WSDL HTTP/1.1
Content-Type: application/soap+xml; charset=UTF-8; action="urn:mediate"
Accept-Encoding: gzip,deflate
Transfer-Encoding: chunked
Host: localhost:5000
Connection: Keep-Alive
User-Agent: Synapse-HttpComponents-NIO
<?xml version='1.0' encoding='UTF-8'?>
<ns1:Envelope xmlns:ns1="http://www.w3.org/2003/05/soap-envelope" xmlns:ns2="http://www.webserviceX.NET/ConversionRate/Input">
<ns1:Body>
<ns2:ConversionRate xmlns:ns2="http://www.webserviceX.NET/">
<ns2:FromCurrency>USD</ns2:FromCurrency>
<ns2:ToCurrency>LKR</ns2:ToCurrency>
</ns2:ConversionRate>
</ns1:Body>
</ns1:Envelope>
This is what the web service returns to the ESB and is also saved in the Out1 file:
Cache-Control: private, max-age=0
Content-Length: 380
Content-Type: application/soap+xml; charset=utf-8
Server: Microsoft-IIS/7.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 23 Jan 2013 15:53:53 GMT
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<ConversionRateResponse xmlns="http://www.webserviceX.NET/">
<ConversionRateResult>127.05</ConversionRateResult>
</ConversionRateResponse>
</soap:Body>
</soap:Envelope>
Hope this helps as with this setup I don't seem to be getting the issue you're having - with the ESB re-wrapping the request. :)
You need to add the following property just above the send mediator (before call your endpoint) to remove the additional soap envelope wrapper from the message.
<property name="messageType" value="application/xml" scope="axis2" type="STRING"/>
I tested it with following sample proxy and it worked for me.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="test"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="messageType"
value="application/xml"
scope="axis2"
type="STRING"/>
<log level="full"/>
<send>
<endpoint>
<address uri="http://www.google.com"/>
</endpoint>
</send>
</inSequence>
</target>
<description/>
</proxy>
Thanks