Home

QtSoapHttpTransport Class Reference

The QtSoapHttpTransport class provides a mechanism for transporting SOAP messages to and from other hosts using the HTTP protocol. More...

#include <qtsoap.h>

List of all member functions.

Public Members

Signals


Detailed Description

The QtSoapHttpTransport class provides a mechanism for transporting SOAP messages to and from other hosts using the HTTP protocol.

Use this class to submit SOAP messages to a web service. Set the hostname of the SOAP server with setHost(). Some servers also require the SOAPAction header to be set, and you can do this with setAction(). Next, submit the request with submitRequest(), passing the message to submit together with the path that you want to submit the message to. The responseReady() signal is emitted when a response has been received. Call getResponse() to get the reponse from the service.

For example: If a SOAP weather service was running on the host weather.example.com, the following code might be used to find the temperature in any given city:

    void WeatherFetcher::findTemperature(const QString &city)
    {
        QtSoapMessage message;
        message.setMethod("getTemperature", "http://weather.example.com/temperature");
        message.setMethodArgument("city", "", city);

        // transport is a private member of WeatherFetcher, of type QtSoapHttpTransport
        transport.setHost("www.example.com");
        connect(&transport, SIGNAL(responseReady()), SLOT(readResponse()));

        transport.submitRequest(message, "/weatherfetcher/fetch.asp");
    }
    

This is an example implementation of the readResponse() slot in the WeatherFetcher class:

    void WeatherFetcher::readResponse()
    {
        const QtSoapMessage &response = transport.getResponse();
        if (response.isFault()) {
            cout << response.faultString().toString().latin1() << endl;
            return;
        }

        const QtSoapType &returnValue = response.returnValue();
        if (returnValue["temperature"].isValid()) {
        cout << "The current temperature is "
             << returnValue["temperature"].toString().latin1()
             << " degrees Celcius." << endl;
    }
    

See also QtSoapMessage and QtSoapType.


Member Function Documentation

QtSoapHttpTransport::QtSoapHttpTransport ( QObject * parent = 0, const char * name = 0 )

Constructs a QtSoapHttpTransport object. Passes parent and name to QObject's constructor.

QtSoapHttpTransport::~QtSoapHttpTransport ()

Destructs a QtSoapHttpTransport.

const QtSoapMessage & QtSoapHttpTransport::getResponse () const

Returns a pointer to the response SOAP message. This message could be a Fault message, so it is wise to check using QtSoapMessage::isFault() before processing the response.

void QtSoapHttpTransport::responseReady () [signal]

This signal is emitted when a SOAP response is received from a remote peer.

See also getResponse().

void QtSoapHttpTransport::setAction ( const QString & action )

Sets the HTTP header SOAPAction to action.

void QtSoapHttpTransport::setHost ( const QString & host, int port = 80 )

Sets the host and port this transport should connect to. Also implicitly sets the HTTP header HOST to host.

void QtSoapHttpTransport::submitRequest ( QtSoapMessage & request, const QString & path )

Submits the SOAP message request to the path path on the HTTP server set using setHost().

This file is part of the Qt Solutions. Copyright © 2003-2006 Trolltech. All Rights Reserved.

Copyright © 2003-2006 TrolltechTrademarks
Qt Solutions