![]() |
Home |
The QtSoapHttpTransport class provides a mechanism for transporting SOAP messages to and from other hosts using the HTTP protocol. More...
#include <QtSoapHttpTransport>
Inherits QObject.
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.
QtSoapHttpTransport usage 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().toLatin1().constData() << endl; return; } const QtSoapType &returnValue = response.returnValue(); if (returnValue["temperature"].isValid()) { cout << "The current temperature is " << returnValue["temperature"].toString().toLatin1().constData() << " degrees Celcius." << endl; }
See also QtSoapMessage and QtSoapType.
Constructs a QtSoapHttpTransport object. Passes parent to QObject's constructor.
Destructs a QtSoapHttpTransport.
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.
Returns a pointer to the QHttp object used by this transport. This is useful if the application needs access to the signals emitted by QHttp.
This signal is emitted when a SOAP response is received from a remote peer.
See also getResponse().
Sets the HTTP header SOAPAction to action.
Sets the host and port this transport should connect to. Also implicitly sets the HTTP header HOST to host.
This is an overloaded member function, provided for convenience.
Sets the host and port this transport should connect to, and the transport connection mode to mode. If port is 0 (the default), the default port number according to the transport mode is used (80 for HTTP, 443 for HTTPS).
Also implicitly sets the HTTP header HOST to host.
Submits the SOAP message request to the path path on the HTTP server set using setHost().
Copyright © 2009 Nokia | Trademarks | Qt Solutions |