[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rif: Re: Problem with POST on a REST web service



Take a look at the SoapUI screenshot you provided. For those who missed it, you can see it here:
http://www.scottklement.com/archives/ftpapi/201509/msg00079.html

Notice the "Post QueryString" checkbox is checked, and the data is NOT provided in the box beneath 'media type' like it would normally be, but instead is provided in a form variable named 'xml'.

HTTP provides two ways of sending application data from the client to the server.

1) Query-string. This works on all HTTP types (GET, POST, PUT, DELETE, etc) but is limited in length. A query string is sent as part of the URL.

2) Request document. This works only with HTTP POST and PUT, but has no length limitation. Unlike query string, it is not part of the URL. After the URL and headers are sent, a document is sent. (Basically, it's a file upload.) The file can be any size -- potentially even terabytes long.

The way you have SoapUI configured, you are sending your XML as a query string. Under the covers, SoapUI is doing this:

POST /personal/ws/offerte_in.php?xml=your-xml-data-is-here HTTP/1.1
Host: portale.ferritalia.it
Content-Length: 0
(no request document sent)

The way you're using HTTPAPI, however, you're sending it like this:

POST /personal/ws/offerte_in.php HTTP/1.1
Host: portale.ferritalia.it
Content-Length: 167
167-bytes-of-xml-data-is-here

If your web service is looking for data in the query string (everything after the ? in a URL is the 'query string') and you're sending it as the request document, then it won't see any data and will fail. If the web service can accept data in the request document, it is a better way to send it -- it's more efficient and has far fewer limitations. However, if the web service doesn't support it in the request document, then you need to change your HTTPAPI code to send it using the query string.

To use query string in HTTPAPI, you would use the "webforms" routines to encode the XML data into a form variable named 'xml', and then add the encoded data onto the URL.




On 9/29/2015 11:42 AM, federico.forsi@xxxxxxxxxxx wrote:
    Thanks to everyboy, sorry, Scott but i don't understand. I perform the
    request using SoapUI like query string.  It is possible to do the same
    with HTTPAPI and, if it is possible, wuold you be so kind to show me
    one example ?
    .
    Please sorry , but i am not expert with this kind of programs.
    Thank to all
    Federico


-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------