Qt- Web service Requests
I'm trying out web service requests using this site as an example:
I got some GET REST request to work, but I' have no idea how to send the XML POST for its advanced search service. This is what I tried:
request.setRawHeader("Content-Type", "text/xml;charset=UTF-8"); request.setUrl(QUrl(request_url_)); QString query = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" "<orgPdbQuery>" "<queryType>org.pdb.query.simple.StructureIdQuery</queryType>" "<description>Simple query for a list of PDB IDs (1 IDs) : 3I5F</description>" "<structureIdList>3I5F</structureIdList>" "</orgPdbQuery>"; QObject::connect(network_, SIGNAL(finished(QNetworkReply*)), this, SLOT(slotRequestFinished(QNetworkReply*))); network_->post(request, query.toUtf8());
void WindowWrapper::slotRequestFinished(QNetworkReply* reply)
if(reply->error() > 0)
qDebug() << reply->errorString();
QByteArray data = reply->readAll();
qDebug() << "Request successful!"; qDebug() << data; }
And this is how i call the method:
There's no error on the request, but i get no response at all...
Does anyone know how can i do this?
It seem that the service from that site only accepts application/x-www-form-urlencoded as Content-Type. Now it's working..