| Home | ![]() |
The QtSoapHttpTransport class provides a mechanism for transporting SOAP messages to and from other hosts using the HTTP protocol. More...
#include <qtsoap.h>
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.
This signal is emitted when a SOAP response is received from a remote peer.
See also getResponse().
This file is part of the Qt Solutions.
Copyright © 2003-2006
Trolltech. All Rights Reserved.
| Copyright © 2003-2006 Trolltech | Trademarks | Qt Solutions
|