I'm trying to use this http://www.rcsb.org/pdb/software/rest.do REST services with Qt. I did some get requests with no problem, but when I try to do a post request to its advanced search(which is an XML web service), I get no response.
This is the post request I'm trying:
<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>
And this is my code for the request:
void WindowWrapper::postRequest()
{
QNetworkRequest request;
QUrl res = QUrl(request_url_);
QUrl query;
query.addQueryItem("queryType","org.pdb.query.simple.StructureIdQuery");
query.addQueryItem("structureIdList","3I5F");
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/octet-stream");
request.setUrl(res);
QObject::connect(network_, SIGNAL(finished(QNetworkReply*)),
this, SLOT(slotRequestFinished(QNetworkReply*)));
network_->post(request, query.encodedQuery());
}
void WindowWrapper::slotRequestFinished(QNetworkReply* reply)
{
if(reply->error() > 0)
{
qDebug() << reply->errorString();
}
else
{
QByteArray data = reply->readAll();
qDebug() << "Request successful!";
qDebug() << data;
}
}
And the method call:
wrapper_->set_request_url("http://www.rcsb.org/pdb/rest/search/");
wrapper_->postRequest();
And on my debug output I get this:
Request successful!
""
Edit:
I also tried this for the request, but I still got no response:
void WindowWrapper::postRequest()
{
QNetworkRequest request;
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());
}
Anyone knows what am I doing wrong? Please...