PDA

View Full Version : Problem with QHttp



mridulgandhi
19th March 2009, 13:23
Hi,

I want to send an XML Schema File to a MULTI-PART server running web-service and the server automatically replies back with an XML File.

I have constructed the Http Header as follows.


QFile infile;
infile.setFileName("Path\\GetInfoSchema.xsd");
if (!infile.open(QIODevice::ReadOnly))
{
return;
}
QByteArray inputStr(infile.readAll());

outfile.setFileName("Path\\webSrvResult.xml");
outfile.open(QIODevice::WriteOnly | QIODevice::Truncate);

QUrl url("webserver/PelletTestWebServiceWeb/");
http->setHost(url.host(), url.port(80));

QHttpRequestHeader header("POST", "http://xyzserver:8080/PelletTestWebServiceWeb/XmlQueryInterface");
header.setValue("multipart/mixed", "application/x-www-form-urlencoded");
http->request(header,inputStr, &outfile);

But the problem is that I am unable to get back the XML document from the server using this. I am being told that this is due to the fact that the server is Multipart.

But I am unable to solve this.

Can anyone please help?

Thanks!

wysota
19th March 2009, 13:35
What do you mean that you are unable to get the xml document back? Don't you receive any response from the server?

mridulgandhi
21st March 2009, 14:50
Yeah I am unable to get the XML from the server because it is a Multi-part server. I don't know how to send multi-part requests in Qt.
Please Help

wysota
21st March 2009, 15:21
So it's not that you can't get something back but rather that you don't know how to send a properly formatted data to the server, right? I suggest you take a network sniffer and intercept a browser connection to the server handling the request and look how the data should be formatted. Alternatively craft an artificial server (like using netcat or a simple hand-written tcp server), get a form that uses multipart formatting, redirect it to your artificial server and use a browser to send such request. Then you'll know how the data should look like. Yet another way is to use a web search engine to find out how multi-part requests are formed.