Hi all,

Today I tried to use the callout mediator with a REST Backend.

The proxy is;

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse";
       name="jaxrsProxy"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <log level="full">
            <property name="MSG" value="PROXY IN"/>
         </log>
         <callout serviceURL="
http://10.100.1.90:9764/jaxrs_basic/services/customers/customerservice/customers
">
            <source type="envelope"/>
         </callout>
         <log level="full">
            <property name="MSG" value="RESPONSE"/>
         </log>
         <property name="RESPONSE" value="true"/>
         <header name="To" action="remove"/>
         <send/>
         <drop/>
      </inSequence>
   </target>
   <description/>
</proxy>

The request to the proxy is:

curl -v -X POST -H "Content-Type: text/xml" -d @customer.xml
http://chamaradell:8280/services/jaxrsProxy

with customer.xml as:

<Customer>
   <name>Jack</name>
</Customer>

And the result in the client side is:

* Adding handle: conn: 0x1860f20
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x1860f20) send_pipe: 1, recv_pipe: 0
* About to connect() to chamaradell port 8280 (#0)
*   Trying 127.0.1.1...
* Connected to chamaradell (127.0.1.1) port 8280 (#0)
> POST /services/jaxrsProxy HTTP/1.1
> User-Agent: curl/7.32.0
> Host: chamaradell:8280
> Accept: */*
> Content-Type: text/xml
> Content-Length: 41
>
* upload completely sent off: 41 out of 41 bytes
< HTTP/1.1 200 OK
< Host: chamaradell:8280
< Content-Type: text/xml
< Accept: */*
< Date: Wed, 08 Jan 2014 12:58:49 GMT
* Server WSO2-PassThrough-HTTP is not blacklisted
< Server: WSO2-PassThrough-HTTP
< Transfer-Encoding: chunked
<
* Connection #0 to host chamaradell left intact
<text xmlns="http://ws.apache.org/commons/ns/payload";>JAXBException
occurred : unexpected element (uri:"
http://schemas.xmlsoap.org/soap/envelope/";, local:"Envelope"). Expected
elements are &lt;{}Customer&gt;. unexpected element (uri:"
http://schemas.xmlsoap.org/soap/envelope/";, local:"Envelope"). Expected
elements are &lt;{}Customer&gt;. </text>

with the wire log in ESB as:

[2014-01-08 18:28:49,074] DEBUG - wire >> "POST /services/jaxrsProxy
HTTP/1.1[\r][\n]"
[2014-01-08 18:28:49,074] DEBUG - wire >> "User-Agent: curl/7.32.0[\r][\n]"
[2014-01-08 18:28:49,074] DEBUG - wire >> "Host: chamaradell:8280[\r][\n]"
[2014-01-08 18:28:49,074] DEBUG - wire >> "Accept: */*[\r][\n]"
[2014-01-08 18:28:49,074] DEBUG - wire >> "Content-Type: text/xml[\r][\n]"
[2014-01-08 18:28:49,074] DEBUG - wire >> "Content-Length: 41[\r][\n]"
[2014-01-08 18:28:49,074] DEBUG - wire >> "[\r][\n]"
[2014-01-08 18:28:49,074] DEBUG - wire >> "<Customer>
<name>Jack</name></Customer>"
[2014-01-08 18:28:49,076]  INFO - LogMediator To: /services/jaxrsProxy,
MessageID: urn:uuid:79ad4f4e-0de4-45b9-8a0a-e2c00aed785c, Direction:
request, MSG = PROXY IN, Envelope: <?xml version="1.0"
encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/";><soapenv:Body><Customer>
<name>Jack</name></Customer></soapenv:Body></soapenv:Envelope>
[2014-01-08 18:28:49,081]  INFO - LogMediator To: /services/jaxrsProxy,
MessageID: urn:uuid:79ad4f4e-0de4-45b9-8a0a-e2c00aed785c, Direction:
request, MSG = RESPONSE, Envelope: <?xml version="1.0"
encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/";><soapenv:Body><text xmlns="
http://ws.apache.org/commons/ns/payload";>JAXBException occurred :
unexpected element (uri:"http://schemas.xmlsoap.org/soap/envelope/";,
local:"Envelope"). Expected elements are &lt;{}Customer&gt;. unexpected
element (uri:"http://schemas.xmlsoap.org/soap/envelope/";,
local:"Envelope"). Expected elements are &lt;{}Customer&gt;.
</text></soapenv:Body></soapenv:Envelope>
[2014-01-08 18:28:49,082] DEBUG - wire << "HTTP/1.1 200 OK[\r][\n]"
[2014-01-08 18:28:49,082] DEBUG - wire << "Host: chamaradell:8280[\r][\n]"
[2014-01-08 18:28:49,082] DEBUG - wire << "Content-Type: text/xml[\r][\n]"
[2014-01-08 18:28:49,082] DEBUG - wire << "Accept: */*[\r][\n]"
[2014-01-08 18:28:49,082] DEBUG - wire << "Date: Wed, 08 Jan 2014 12:58:49
GMT[\r][\n]"
[2014-01-08 18:28:49,082] DEBUG - wire << "Server:
WSO2-PassThrough-HTTP[\r][\n]"
[2014-01-08 18:28:49,083] DEBUG - wire << "Transfer-Encoding:
chunked[\r][\n]"
[2014-01-08 18:28:49,083] DEBUG - wire << "[\r][\n]"
[2014-01-08 18:28:49,083] DEBUG - wire << "15a[\r][\n]"
[2014-01-08 18:28:49,083] DEBUG - wire << "<text xmlns="
http://ws.apache.org/commons/ns/payload";>JAXBException occurred :
unexpected element (uri:"http://schemas.xmlsoap.org/soap/envelope/";,
local:"Envelope"). Expected elements are &lt;{}Customer&gt;. unexpected
element (uri:"http://schemas.xmlsoap.org/soap/envelope/";,
local:"Envelope"). Expected elements are &lt;{}Customer&gt;.
</text>[\r][\n]"
[2014-01-08 18:28:49,083] DEBUG - wire << "0[\r][\n]"
[2014-01-08 18:28:49,083] DEBUG - wire << "[\r][\n]"


Does anyone know how to use callout mediator with a REST backend, and how
to overcome this failure situation?

-- 
*Chamara Ariyarathne*
Senior Software Engineer - QA;
WSO2 Inc; http://www.wso2.com/.
Mobile; *+94772786766*
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to