Hi Thilini,

Thank you for the explanation and according to Buddhimala I have added a
custom response for the status code 202 and it works fine.

Thanks.
Piriya

On Mon, Nov 20, 2017 at 9:53 AM, Thilini Shanika <[email protected]> wrote:

> Hi Priya,
>
> It seems like you are getting a SOAP response with an empty 
> body(<soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";><s
> oapenv:Body/></soapenv:Envelope>) so that the JSON conversion fails. What
> is the requirement here to convert an empty SOAP message into a JSON? If
> you are getting an empty SOAP body for a delete operation, there's no point
> of converting it to a JSON, instead, you can return an HTTP status
> code(200).
>
> On Fri, Nov 17, 2017 at 10:32 AM, Piriya Sivalingam <[email protected]>
> wrote:
>
>> Hi,
>>
>> I am seeing an error in ESB 5.0.0 when making SOAP to JSON conversion via
>> a proxy service. When I invoke the proxy using following curl command the
>> operation was successful, but I could see some errors logged in the console.
>>
>> When I search for the error, I found a solution given in [1]. When I try
>> it, the error got resolved. But still, I am getting a SOAP payload as the
>> response message.
>>
>> Here is my proxy service.
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <proxy xmlns="http://ws.apache.org/ns/synapse";
>>        name="newproxy1.2"
>>        startOnLoad="true"
>>        statistics="disable"
>>        trace="disable"
>>        transports="http,https">
>>    <target>
>>       <inSequence>
>>          <header name="Authorization"
>>                  scope="transport"
>>                  value="Basic cGlyaXlhOnBpcml5YTEyMw=="/>
>>          <log>
>>             <property expression="$axis2:HTTP_METHOD" name="httpmethod
>> === "/>
>>          </log>
>>          <switch source="$axis2:HTTP_METHOD">
>>             <case regex="^(.*(GET)).*$">
>>                <payloadFactory media-type="xml">
>>                   <format>
>>                      <soapenv:Envelope xmlns:soapenv="http://schemas.
>> xmlsoap.org/soap/envelope/"
>>                                        xmlns:ser="http://service.sam
>> ple.ninewells.com">
>>                         <soapenv:Header>
>>                            <abc>2611</abc>
>>                         </soapenv:Header>
>>                         <soapenv:Body>
>>                            <ser:readNinewells>
>>                               <ser:patientId>$1</ser:patientId>
>>                            </ser:readNinewells>
>>                         </soapenv:Body>
>>                      </soapenv:Envelope>
>>                   </format>
>>                   <args>
>>                      <arg xmlns:ns="http://org.apache.synapse/xsd";
>>                           evaluator="xml"
>>                           expression="$url:patientId"/>
>>                   </args>
>>                </payloadFactory>
>>                <property name="SOAPAction"
>>                          scope="transport"
>>                          type="STRING"
>>                          value="urn:readNinewells"/>
>>                <header name="Action" scope="default"
>> value="urn:readNinewells"/>
>>                <property name="messageType"
>>                          scope="axis2"
>>                          type="STRING"
>>                          value="application/xml"/>
>>                <send>
>>                   <endpoint>
>>                      <address format="soap11"
>>                               uri="https://<IP>:<PORT>/servi
>> ces/NinewellsPatientService"/>
>>                   </endpoint>
>>                </send>
>>             </case>
>>             <case regex="^(.*(DELETE)).*$">
>>                <payloadFactory media-type="xml">
>>                   <format>
>>                      <soapenv:Envelope xmlns:soapenv="http://schemas.
>> xmlsoap.org/soap/envelope/"
>>                                        xmlns:ser="http://service.sam
>> ple.ninewells.com">
>>                         <soapenv:Header>
>>                            <abc>2611</abc>
>>                         </soapenv:Header>
>>                         <soapenv:Body>
>>                            <ser:deleteNinewells>
>>                               <ser:patientId>$1</ser:patientId>
>>                            </ser:deleteNinewells>
>>                         </soapenv:Body>
>>                      </soapenv:Envelope>
>>                   </format>
>>                   <args>
>>                      <arg xmlns:ns="http://org.apache.synapse/xsd";
>>                           evaluator="xml"
>>                           expression="$url:patientId"/>
>>                   </args>
>>                </payloadFactory>
>>                <property name="SOAPAction"
>>                          scope="transport"
>>                          type="STRING"
>>                          value="urn:deleteNinewells"/>
>>                <header name="Action" scope="default"
>> value="urn:deleteNinewells"/>
>>                <property name="messageType"
>>                          scope="axis2"
>>                          type="STRING"
>>                          value="application/xml"/>
>>                <send>
>>                   <endpoint>
>>                      <address format="soap11"
>>                               uri="https://<IP>:<PORT>/servi
>> ces/NinewellsPatientService"/>
>>                   </endpoint>
>>                </send>
>>             </case>
>>             <default/>
>>          </switch>
>>       </inSequence>
>>       <outSequence>
>>          <property name="messageType"
>>                    scope="axis2"
>>                    type="STRING"
>>                    value="application/json"/>
>>          <send/>
>>       </outSequence>
>>    </target>
>>    <description/>
>> </proxy>
>>
>> My curl command is  curl -X DELETE http://piriya-ThinkPad-X1-Carb
>> on-5th:8284/services/newproxy1.2?patientId=1031
>>
>> The exception in the console is:
>>
>> ERROR - JsonUtil #writeAsJson. Payload could not be written as JSON.
>> MessageID: urn:uuid:752a8cd2-03a7-4564-8645-7652db5c8666
>> [2017-11-17 10:06:30,700] ERROR - PassThroughHttpSender Failed to submit
>> the response
>> org.apache.axis2.AxisFault: Payload could not be written as JSON.
>> at org.apache.synapse.commons.json.JsonUtil.writeAsJson(JsonUti
>> l.java:264)
>> at org.apache.synapse.commons.json.JsonStreamFormatter.writeTo(
>> JsonStreamFormatter.java:61)
>> at org.apache.synapse.transport.passthru.PassThroughHttpSender.
>> submitResponse(PassThroughHttpSender.java:566)
>> at org.apache.synapse.transport.passthru.PassThroughHttpSender.
>> invoke(PassThroughHttpSender.java:264)
>> at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
>> at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Send
>> er.java:222)
>> at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(A
>> xis2SynapseEnvironment.java:531)
>> at org.apache.synapse.mediators.builtin.SendMediator.mediate(Se
>> ndMediator.java:118)
>> at org.apache.synapse.mediators.AbstractListMediator.mediate(Ab
>> stractListMediator.java:97)
>> at org.apache.synapse.mediators.AbstractListMediator.mediate(Ab
>> stractListMediator.java:59)
>> at org.apache.synapse.mediators.base.SequenceMediator.mediate(S
>> equenceMediator.java:158)
>> at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.inject
>> Message(Axis2SynapseEnvironment.java:337)
>> at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handle
>> Message(SynapseCallbackReceiver.java:560)
>> at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receiv
>> e(SynapseCallbackReceiver.java:194)
>> at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
>> at org.apache.synapse.transport.passthru.ClientWorker.run(Clien
>> tWorker.java:260)
>> at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.
>> run(NativeWorkerPool.java:172)
>> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPool
>> Executor.java:1142)
>> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoo
>> lExecutor.java:617)
>> at java.lang.Thread.run(Thread.java:748)
>> [2017-11-17 10:06:30,702] ERROR - Axis2Sender
>> Content-Type:application/json,<?xml version='1.0'
>> encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.
>> xmlsoap.org/soap/envelope/"><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:624)
>> at org.apache.synapse.transport.passthru.PassThroughHttpSender.
>> invoke(PassThroughHttpSender.java:266)
>> at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
>> at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Send
>> er.java:222)
>> at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(A
>> xis2SynapseEnvironment.java:531)
>> at org.apache.synapse.mediators.builtin.SendMediator.mediate(Se
>> ndMediator.java:118)
>> at org.apache.synapse.mediators.AbstractListMediator.mediate(Ab
>> stractListMediator.java:97)
>> at org.apache.synapse.mediators.AbstractListMediator.mediate(Ab
>> stractListMediator.java:59)
>> at org.apache.synapse.mediators.base.SequenceMediator.mediate(S
>> equenceMediator.java:158)
>> at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.inject
>> Message(Axis2SynapseEnvironment.java:337)
>> at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handle
>> Message(SynapseCallbackReceiver.java:560)
>> at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receiv
>> e(SynapseCallbackReceiver.java:194)
>> at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
>> at org.apache.synapse.transport.passthru.ClientWorker.run(Clien
>> tWorker.java:260)
>> at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.
>> run(NativeWorkerPool.java:172)
>> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPool
>> Executor.java:1142)
>> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoo
>> lExecutor.java:617)
>> at java.lang.Thread.run(Thread.java:748)
>> Caused by: org.apache.axis2.AxisFault: Payload could not be written as
>> JSON.
>> at org.apache.synapse.commons.json.JsonUtil.writeAsJson(JsonUti
>> l.java:264)
>> at org.apache.synapse.commons.json.JsonStreamFormatter.writeTo(
>> JsonStreamFormatter.java:61)
>> at org.apache.synapse.transport.passthru.PassThroughHttpSender.
>> submitResponse(PassThroughHttpSender.java:566)
>> at org.apache.synapse.transport.passthru.PassThroughHttpSender.
>> invoke(PassThroughHttpSender.java:264)
>>
>>
>> [1] [Dev] [ESB] JSON to SOAP conversion issue
>>
>> Could you please suggest how I can overcome this issue or correct me if I
>> am wrong?
>>
>> Thanks,
>> Piriya
>>
>>
>> --
>> Regards,
>>
>> *Piriya Sivalingam*
>>
>> *Software Engineer - Support Team*
>>
>> *WSO2*
>> *Mobile : +94 77 8462039 <+94%2077%20846%202039>*
>>
>> [image: http://wso2.com/signature] <http://wso2.com/signature>
>>
>>
>> _______________________________________________
>> Dev mailing list
>> [email protected]
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> Thilini Shanika
> Senior Software Engineer
> WSO2, Inc.; http://wso2.com
> 20, Palmgrove Avenue, Colombo 3
>
> E-mail: [email protected]
>
>


-- 
Regards,

*Piriya Sivalingam*

*Software Engineer - Support Team*

*WSO2*
*Mobile : +94 77 8462039*

[image: http://wso2.com/signature] <http://wso2.com/signature>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to