Further, if you need the Content-Length to be present you need to add the following too;
<syn:property name="FORCE_HTTP_1.0" value="true" scope="axis2"/> in to the inSequence. By default ESB uses HTTP 1.1 with chunking in which case the Content-Length is not there in the HTTP headers. Thanks, Ruwan Keith Chapman wrote: > Hi Harm, > > Here is how you could do it. You need to set two properties (at the > axis2 scope), The following is a sample config > > <?xml version="1.0" encoding="UTF-8"?> > <syn:definitions xmlns:syn="http://ws.apache.org/ns/synapse"> > <syn:registry provider="org.wso2.esb.registry.ESBRegistry"> > <syn:parameter name="root">file:registry/</syn:parameter> > </syn:registry> > <syn:proxy name="RESTProxy" startOnLoad="true"> > <syn:target> > <syn:endpoint name="RESTEndpoint"> > <syn:address > uri="http://localhost:7763/services/keith/test/foo" format="pox"/> > </syn:endpoint> > <syn:inSequence> > <syn:property name="messageType" > value="application/x-www-form-urlencoded" scope="axis2"/> > <syn:property name="HTTP_METHOD" value="post" > scope="axis2"/> > </syn:inSequence> > </syn:target> > </syn:proxy> > <syn:sequence name="main"> > <syn:send/> > </syn:sequence> > <syn:sequence name="fault"> > <syn:log/> > </syn:sequence> > </syn:definitions> > > Sample messages are: > > Request coming into ESB: > > POST /soap/RESTProxy/mediate HTTP/1.1 > Content-Type: application/soap+xml; charset=UTF-8; > action="urn:anonOutInOp" > User-Agent: WSO2 Mashup Server - Version 1.5.1 > Host: 127.0.0.1 > Content-Length: 191 > > <?xml version='1.0' encoding='UTF-8'?> > <soapenv:Envelope > xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> > <soapenv:Body> > <foo> > <param>keith</param> > </foo> > </soapenv:Body> > </soapenv:Envelope> > > Message Sent out by ESB: > > POST http://localhost:7763/services/keith/test/foo HTTP/1.1 > Host: 127.0.0.1 > Content-Type: application/x-www-form-urlencoded; > charset=UTF-8;action="urn:anonOutInOp"; > Transfer-Encoding: chunked > Connection: Keep-Alive > User-Agent: Synapse-HttpComponents-NIO > > b > param=keith > 0 > > Thanks, > Keith. > > Harm Verhagen wrote: >> I'm trying to figure out how to call a legacy HTTP interface from >> the esb bus. >> >> It expects an URL: http://host/issue?voucher='xml >> <http://host/issue?voucher=%27xml> document' with an http POST. >> >> sequence: >> 1) receive a soap request (proxy) >> 2) xlst mediator (builds the xml document to be posted). >> 3) then a POX endpoint with URl http://host/issue >> >> 1. The message send to the server however doesn't have >> "Content-Length:" set. >> 2. The start of the http POST part "voucher=" is missing. >> 3. Also It isn't Content-Type: application/x-www-form-urlencoded but >> rather application/xml; charset=UTF-8 >> (It can be www-form-urlencoded... with REST/GET but then its not a >> POST...) >> >> Any idea how I can make it application/x-www-form-urlencoded, and >> with the voucher= parameter. >> >> >> >> *example of a working (without esb) call* >> POST /vts/issue HTTP/1.1 >> Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXX >> User-Agent: Jakarta Commons-HttpClient/3.1 >> Host: XX.XX.XX >> Cookie: $Version=0; JSESSIONID=16ami6ulq3mqr; $Path=/vts >> Content-Length: 358 >> Content-Type: application/x-www-form-urlencoded >> >> voucher=%3C%3Fxml+version%3D%221.0%22+encoding%3D%22UTF-8%22%3F%3E%0A%3CVoucher+xmlns%3D%22urn%3Aietf%3Aparams%3Axml%3Ans%3Avts-issue%22+title%3D%22dfdadfdsfsa%22+key%3D%221233455%22+ean8%3D%221233455%22%3E%3CDescription%3Egsfdgfdgf%3C%2FDescription%3E%3CIssuer+name%3D%22op%22%2F%3E%3CHolder+phone-number%3D%22%2B31655325465%22%2F%3E%3C%2FVoucher%3E >> >> *What I got now* >> POST http://192.168.6.108:100/vts/issue?voucher= HTTP/1.1 >> Host: XX.XX.XX.XX >> Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXX >> SOAPAction: "" >> Content-Type: application/xml; charset=UTF-8 >> Transfer-Encoding: chunked >> Connection: Keep-Alive >> User-Agent: Synapse-HttpComponents-NIO >> >> d7 >> <Voucher xmlns="urn:ietf:params:xml:ns:vts-issue" ean8="123456" >> key="123456" title="Hier is uw ticket"> >> <Description>Bla</Description> >> <Issuer name="op" /> >> <Holder email="[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>" /> >> </Voucher> >> 0 >> >> >> >> Regards, >> Harm >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Esb-java-user mailing list >> [email protected] >> http://mailman.wso2.org/cgi-bin/mailman/listinfo/esb-java-user >> > > ------------------------------------------------------------------------ > > _______________________________________________ > Esb-java-user mailing list > [email protected] > http://mailman.wso2.org/cgi-bin/mailman/listinfo/esb-java-user > _______________________________________________ Esb-java-user mailing list [email protected] http://mailman.wso2.org/cgi-bin/mailman/listinfo/esb-java-user
