Qt-based BB10 API Examples Documentation

Contents

QtSoapMessage Class Reference

The QtSoapMessage class provides easy access to SOAP messages. More...

    #include <QtSoapMessage>

Public Types

enum FaultCode { VersionMismatch, MustUnderstand, Client, Server }

Public Functions

QtSoapMessage ()
QtSoapMessage ( const QtSoapMessage & copy )
~QtSoapMessage ()
void addBodyItem ( QtSoapType * item )
void addFaultDetail ( QtSoapType * detail )
void addHeaderItem ( QtSoapType * item )
void addMethodArgument ( QtSoapType * arg )
void addMethodArgument ( const QString & name, const QString & uri, const QString & value )
void addMethodArgument ( const QString & name, const QString & uri, bool value, int dummy )
void addMethodArgument ( const QString & name, const QString & uri, int value )
void clear ()
QString errorString () const
FaultCode faultCode () const
const QtSoapType & faultDetail () const
const QtSoapType & faultString () const
bool isFault () const
const QtSoapType & method () const
const QtSoapType & returnValue () const
bool setContent ( QDomDocument & d )
bool setContent ( const QByteArray & buffer )
void setFaultCode ( FaultCode code )
void setFaultString ( const QString & s )
void setMethod ( const QtSoapQName & meth )
void setMethod ( const QString & name, const QString & uri = QString::null )
QString toXmlString ( int indent = 0 ) const
QtSoapMessage & operator= ( const QtSoapMessage & copy )

Protected Types

enum MessageType { Fault, MethodRequest, MethodResponse, OtherType }

Protected Functions

QtSoapStruct & body () const
QtSoapStruct & header () const
bool isValidSoapMessage ( const QDomDocument & candidate )

Detailed Description

The QtSoapMessage class provides easy access to SOAP messages.

With this class, you can create and inspect any SOAP message. There are convenience functions available for generating the most common types of SOAP messages, and any other messages can be constructed manually using addBodyItem().

Use setMethod() and addMethodArgument() to construct a method request. The return value of a method response is available from returnValue().

Use setFaultCode(), setFaultString() and addFaultDetail() to construct a Fault message. To inspect a Fault message, use faultCode(), faultString() and faultDetail().

To add items to the body part of the SOAP message, use addBodyItem(). To add items to the header, use addHeaderItem().

toXmlString() returns a QString XML representation of the SOAP message. clear() resets all content in the message, creating an empty SOAP message.

    QtSoapMessage message;

    message.setMethod("getTemperature", "http://weather.example.com/temperature");
    message.addMethodArgument("city", "Oslo");

    // Get the SOAP message as an XML string.
    QString xml = message.toXmlString();

QtSoap provides a partial implementation of version 1.1 of the SOAP protocol as defined in http://www.w3.org/TR/SOAP/.

Server side SOAP is not supported. References to values (id and href attributes) are not supported. Arrays support a maximum of five dimensions. Namespaces for types are not checked. Only the type names are used. The encodingStyle attribute is ignored. The serialization and encoding rules from section 5 in the SOAP v1.1 specification are assumed regardless of the value of the encodingStyle attribute. QtSoapType does not have accessors for attributes, which means for example that actor, mustUnderstand and so on are not accessible in headers. The SOAP root attribute is not supported.

See also QtSoapType, QtSoapQName, and QtSoapHttpTransport.

Member Type Documentation

enum QtSoapMessage::FaultCode

This enum describes all the supported SOAP Fault codes:

ConstantValueDescription
QtSoapMessage::VersionMismatch0The namespace for the Envelope element was unrecognized by the remote SOAP server. This usually means that the remote server does not support version 1.1 of the SOAP protocol.
QtSoapMessage::MustUnderstand1One of the header items in the SOAP message with a "MustUnderstand" attribute was not recognized by the remote server.
QtSoapMessage::Client2An error in the SOAP message or transport prevents further processing by the remote SOAP server.
QtSoapMessage::Server3An error in the remote SOAP server prevents it from processing the SOAP message.

enum QtSoapMessage::MessageType

ConstantValue
QtSoapMessage::Fault0
QtSoapMessage::MethodRequest1
QtSoapMessage::MethodResponse2
QtSoapMessage::OtherType3

Member Function Documentation

QtSoapMessage::QtSoapMessage ()

Constructs an empty QtSoapMessage. The message only contains the Envelope element, with no header and no body.

QtSoapMessage::QtSoapMessage ( const QtSoapMessage & copy )

Constructs a copy of copy.

QtSoapMessage::~QtSoapMessage ()

Destructs a QtSoapMessage.

void QtSoapMessage::addBodyItem ( QtSoapType * item )

Adds item to the body in the SOAP message. The item is added after the last existing item in the body.

void QtSoapMessage::addFaultDetail ( QtSoapType * detail )

Adds the QtSoapType detail to the end of the list of faultdetail items in a SOAP Fault message.

void QtSoapMessage::addHeaderItem ( QtSoapType * item )

Adds item to the header in the SOAP message. The item is added after the last existing item in the header.

void QtSoapMessage::addMethodArgument ( QtSoapType * arg )

Adds argument arg to the list of arguments that are passed in a SOAP method request.

Warning: setMethod() must be called before calling this function.

void QtSoapMessage::addMethodArgument ( const QString & name, const QString & uri, const QString & value )

This is an overloaded function.

Adds an argument called name with a uri of uri. The type of the argument is QtSoapType::String and its value is value.

void QtSoapMessage::addMethodArgument ( const QString & name, const QString & uri, bool value, int dummy )

This is an overloaded function.

Adds an argument called name with a uri of uri. The type of the argument is QtSoapType::Boolean and its value is value.

The dummy argument is used to distinguish this function from the overload which takes an int.

void QtSoapMessage::addMethodArgument ( const QString & name, const QString & uri, int value )

This is an overloaded function.

Adds an argument called name with a uri of uri. The type of the argument is QtSoapType::Integer and its value is value.

QtSoapStruct & QtSoapMessage::body () const [protected]

Returns a reference to the body of the SOAP message.

void QtSoapMessage::clear ()

Clears the content of the SOAP message.

QString QtSoapMessage::errorString () const

Returns a human readable explanation of the most recent error that occurred in the QtSoapMessage.

FaultCode QtSoapMessage::faultCode () const

Returns the Fault faultcode element of a SOAP Fault message.

See also setFaultCode().

const QtSoapType & QtSoapMessage::faultDetail () const

Returns the Fault detail element of a SOAP Fault message.

const QtSoapType & QtSoapMessage::faultString () const

Returns the Fault faultstring element of a SOAP Fault message.

See also setFaultString().

QtSoapStruct & QtSoapMessage::header () const [protected]

Returns a reference to the header of the SOAP message.

bool QtSoapMessage::isFault () const

Returns true if the message is a SOAP Fault message; otherwise returns false.

bool QtSoapMessage::isValidSoapMessage ( const QDomDocument & candidate ) [protected]

Validates the QDomDocument candidate using some simple heuristics. Returns true if the document is a valid SOAP message; otherwise returns false.

const QtSoapType & QtSoapMessage::method () const

Returns the method of a SOAP method request or response as a QtSoapType.

See also setMethod().

const QtSoapType & QtSoapMessage::returnValue () const

Returns the return value of a SOAP method response as a QtSoapType.

bool QtSoapMessage::setContent ( QDomDocument & d )

Imports the QDomDocument d if it validates as a SOAP message. Any existing message content is replaced.

If the import fails, this message becomes a Fault message.

Returns true if the import succeeds, otherwise false.

bool QtSoapMessage::setContent ( const QByteArray & buffer )

This is an overloaded function.

Parses the XML document in buffer. Imports the document if it validates as a SOAP message. Any existing message content is replaced.

If the import fails, this message becomes a Fault message.

Returns true if the import succeeds, otherwise false.

void QtSoapMessage::setFaultCode ( FaultCode code )

Sets the fault code of the SOAP Fault message to code.

See also faultCode().

void QtSoapMessage::setFaultString ( const QString & s )

Sets the Fault faultstring of the SOAP Fault message to s.

See also faultString().

void QtSoapMessage::setMethod ( const QtSoapQName & meth )

Sets the QName (qualified name) of the method to call in a SOAP method request to meth.

This function must be called before calling addMethodArgument().

See also method().

void QtSoapMessage::setMethod ( const QString & name, const QString & uri = QString::null )

This is an overloaded function.

Sets the method name to name and uri to uri.

QString QtSoapMessage::toXmlString ( int indent = 0 ) const

Returns the XML representation of the SOAP message as a QString, optionally indenting using indent spaces.

QtSoapMessage & QtSoapMessage::operator= ( const QtSoapMessage & copy )

Makes this message a copy of copy.