Logo Search packages:      
Sourcecode: kmess version File versions


                          httpsoapconnection.h -  description
    begin                : Sun Sep 25 2005
    copyright            : (C) 2005 by Diederik van der Boor
    email                : vdboor --at-- codingdomain.com

 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *


#include "../tcpconnectionbase.h"

#include <kurl.h>

#include <qdom.h>

class SoapMessage;
class MimeMessage;

 * @brief SOAP transport over a HTTP connection.
 * The SOAP protocol is used to implement webservices.
 * It's commonly used by .Net applications,
 * MSN Messenger is not an exception here.
 * SOAP is used for new features like:
 * - games / activities.
 * - offline-im.
 * - passport 3.0 authentication.
 * - addressbook data (as of Windows Live Messenger).
 * The class implements SOAP at a basic level.
 * - it operates much like the <code>XmlHttpRequest</code> class works in web browsers.
 * - sniffed XML strings can be sent directly with sendRequest().
 * - no need to translate XML to SOAP encodings.
 * - no need to reverse engineer a WSDL to send SOAP messages.
 * - http://wanderingbarque.com/nonintersecting/2006/11/15/the-s-stands-for-simple/
 * The SOAP result message is returned as QDomElement, which
 * can be traversed to access the returned data structures.
 * This class can be used in two ways: either extend the object to implement the calls,
 * or connect to the signals this class emits. Most classes only need to call sendRequest()
 * and connect to the signals for a response. It's recommended to create a derived class which
 * offers all methods exported by the webservice. This class can also process the
 * the response from slotRequestFinished().
 * @author Diederik van der Boor
 * @ingroup NetworkExtra
00062 class HttpSoapConnection : public TcpConnectionBase

  public:  // public methods
    // The constructor
                         HttpSoapConnection( const QString &endpoint, QObject *parent = 0, const char *name = "HttpSoapConnection" );
    // The destructor
    virtual             ~HttpSoapConnection();

    // Close the connection
    virtual void         closeConnection();

    // Return the endpoint
    QString              getEndpoint() const;
    // Whether the connection is idle, not processing a SOAP request/response
    bool                 isIdle();
    // Return the received HTTP status code
    int                  getHttpStatusCode() const;
    // Return the last request ID
    const QString &      getRequestId() const;
    // Return the last SOAP action
    const QString &      getSoapAction() const;

    // Send a SOAP request
    void                 sendRawPostRequest( const QString &content, const QString &soapAction = QString::null, const QString &requestId = QString::null );
    // Send a SOAP request
    void                 sendRequest( const QString &soapAction, const SoapMessage &message, const QString &requestId = QString::null );
    // Send a SOAP request
    void                 sendRequest( const QString &soapAction, const QString &messageBody, const QString &messageHeader = QString::null, const QString &requestId = QString::null );

    // Escape a string for inclusion in XML
    QString              escapeString( QString value ) const;
    // Parse the HTTP header
    virtual bool         parseHttpHeader( const QString &preamble, const MimeMessage &header );
    // The connection received the full response
    virtual bool         parseHttpBody( const QByteArray &responseBody );
    // The connection failed
    virtual void         slotConnectionFailed();
    // The connection's request failed
    virtual void         slotRequestFailed( const QString &faultCode, const QString &faultString, QDomElement &faultNode );
    // The connection's request completed
    virtual void         slotRequestFinished( QDomElement &resultRoot );

    // Connect to the endpoint
    bool                 connectToEndpoint();
    // The connection is established
    void                 slotConnectionEstablished();
    // The connection received data
    void                 slotDataReceived();

  private:  // private attributes
    /// The endpoint for the request
00117     KURL                 endpoint_;
    /// Whether the server requests to keep the connection alive
00119     bool                 keepAlive_;
    /// Whether there is a parsing error.
00121     bool                 parseError_;
    /// The message to be sent
00123     QCString             request_;
    /// Whether there is an request active.
00125     bool                 requestActive_;
    /// The remote ID of the request.
00127     QString              requestId_;
    /// The response code
00129     uint                 responseCode_;
    /// The length of the response
00131     uint                 responseLength_;
    /// The last SOAP action
00133     QString              soapAction_;

     * @brief Fired when another error occured.
     * @param  client  The object sending the signal.
     * @param  reason  The message to display in the user interface.
    void                 requestFailed( HttpSoapConnection *client, const QString &reason );

     * @brief Fired when the SOAP request returned a SOAP fault.
     * @param  client       The object sending the signal.
     * @param  faultCode    The SOAP fault code.
     * @param  faultString  The SOAP fault string value.
     * @param  faultNode    The XML node of the SOAP fault, to extract custom fields if needed.
    void                 requestFailed( HttpSoapConnection *client, const QString &faultCode,
                                        const QString &faultString, QDomElement faultNode );
     * @brief Fired when a query completed.
     * @param  client      The object sending the signal.
     * @param  resultRoot  The XML response sent by the SOAP server.
    void                 requestFinished( HttpSoapConnection *client, QDomElement resultRoot );


Generated by  Doxygen 1.6.0   Back to index