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:

    void WindowWrapper::postRequest()
    QNetworkRequest request;

    request.setRawHeader("Content-Type", "text/xml;charset=UTF-8");
    QString query =
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
            "<description>Simple query for a list of PDB IDs (1 IDs) : 3I5F</description>"
    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..

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.