How can I get right format " Text/XML" in response from ESB

samba's picture

Hi,

1 - I want to configure a proxy for a REST Service which suppose to return a bloc of XML as in a web browser.
Can you give me me the right propreties to set in my proxy configuration. I try severals
solutions but it doesn't not work.
- using format="pox" in the endpoint
- using sequence with this sample http://www.keith-chapman.org/2008/10/apache-synapsewso2-esb-calling-rest.html
- and so ...
2 - I understand that when I create a new proxy it's suppose to work as a REST service is it correct ?
But how can I invoke my proxy service just for to get my XML bloc information in the right format (xml/text for response)instead of a soap message.

Thanks

indika's picture

Hi For 1) ESB supports the

Hi

For 1) ESB supports the REST based on the WSDL2 HTTP binding. please look at [1]. You need to set properly HTTP-binding (whttp:location etc) in the WSDL. There were a few issues in 3.0.0 release and most of them have been fixed in the current SVN trunk code base.

if you are just proxing HTTP get or post calls, your issue may be [2], if so , there is a solution for it in the given post.

For 2) Some HTTP headers including 'Content-Type' is determined by the HTTP transport and 'Message Formatter'. We actually remove all those headers prior to give message to the transport. Therefore, to change 'Content-Type', you have to change 'Message Formatter'. It may not work for all cases successfully.

Thanks

Indika

[1] http://wso2.org/library/3726

[2] http://wso2.org/forum/thread/9787#comment-14338

samba's picture

Ok, I mean that the message

Ok,
I mean that the message is sent to my ESB as a XML format, my log mediator shows me a message in binary format.
Then the response message also is formated in binary and encapsulate in a SOAP env.
I just need to receive my response as a xml without soap env.
You mean that I have to change the message formatter in axix2.xml so which one is the good for xml ?

samba's picture

It works

Yes it works !!
I change the using MessageFormatter in axis2.xml and add contenType in my proxy configuration.

Thanks

indika's picture

nice to here that Indika

nice to here that

Indika

hdhanoa.westernasset.com's picture

 I have the exact same

 I have the exact same problem except I didn't received the response when hitting the Browser I have a simple use case of #1 (Rest Proxy that can be hit by apache http-client or with the browser & give the simple text result ( ..returning a date field) like 
http://localhost:8280/services/MyProxy/method?param1=hello&param2=wso2
I am tring to understand how to pass the REST parameters (I already set the "POST_TO_URI" and format="get" and also try changing the MessageFormatters...does not work )

Can you also post your exact changes ?

here is my proxy:
<code>
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="CalendarRestProxy" transports="http" startOnLoad="true" trace="enable" statistics="enable">
    <target>
        <inSequence>
          <property name="POST_TO_URI" value="true" scope="axis2"/>
</inSequence>
       <endpoint name="enddpoint_212399">
            <address uri="http://devserver1/appName/services/rest/Employee" format="get"/>
        </endpoint>
        <outSequence>
            <log level="full"/>
            <send/>
        </outSequence>
    </target>
</code>
I see the logs &  request is using the soap envelope  & showing following error 
2010-07-29 16:22:19,623 [-] [HttpClientWorker-1]  WARN ClientWorker Unexpected response received. HTTP response code : 405 HTTP status : Method Not Allowed exception : com.ctc.wstx.exc.WstxParsingException: Unexpected close tag </body>; expected </HR>.
 at [row,col {unknown-source}]: [1,968]
2010-07-29 16:22:19,639 [-] [HttpClientWorker-1] ERROR NativeWorkerPool Uncaught exception
java.lang.ClassCastException: org.apache.axiom.om.impl.llom.OMTextImpl cannot be cast to org.apache.axiom.om.OMElement
at org.apache.synapse.util.MessageHelper.cloneSOAPFault(MessageHelper.java:439)
at org.apache.synapse.util.MessageHelper.cloneSOAPEnvelope(MessageHelper.java:254)
at org.apache.synapse.core.axis2.SOAPUtils.convertSOAP11toSOAP12(SOAPUtils.java:94)

 

hdhanoa.westernasset.com's picture

any idea ?

any idea ?

Hot Topic
Hot
Topic

Google Gadgets are a nice way to develop user interfaces for distributed services. The fact that they can be hosted anywhere over a network, not necessarily in the very portal server they eventually run in makes them re-usable and allows users to quickly...

Latest Webinar
In this webinar we'll share the range of concerns we've heard from the industry, and survey some of the new and sometimes subtle types of lock-in associated with cloud technologies.
Wednesday, 8 September, 10.00 AM (PDT)