Friday, July 16, 2010

How to generate HTTP 1.0 requests

While verifying some scenarios with WSO2 ESB I had the need to send HTTP 1.0 POST messages. Then came cURL to the rescue. I just had to use the option -0 or --http1.0 when sending the request like shown below.

$ curl -s "http://localhost:8280/services/Axis2Service" -d @soap11_echoString.xml -H "Content-Type:text/xml; charset=UTF-8" -H "SOAPAction: urn:echoString" -0

Or

$ curl -s "http://localhost:8280/services/Axis2Service" -d @soap11_echoString.xml -H "Content-Type:text/xml; charset=UTF-8" -H "SOAPAction: urn:echoString" --http1.0

When viewed through TCPMon, you will see how it sends a HTTP 1.0 message

POST /services/Axis2Service HTTP/1.0
User-Agent: curl/7.18.2 (x86_64-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.10
Host: 127.0.0.1:7001
Accept: */*
Content-Type:text/xml; charset=UTF-8
SOAPAction: urn:echoString
Content-Length: 273

<?xml version='1.0' encoding='UTF-8'?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ser:echoString xmlns:ser="http://service.carbon.wso2.org">
<ser:s>Hello!!!</ser:s>
</ser:echoString>
</soap:Body>
</soap:Envelope>

No comments: