psoap.h
Go to the documentation of this file.
/*
* psoap.h
*
* SOAP client / server classes.
*
* Portable Windows Library
*
* Copyright (c) 2003 Andreas Sikkema
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Portable Windows Library.
*
* The Initial Developer of the Original Code is Andreas Sikkema
*
* Contributor(s): ______________________________________.
*
* $Revision: 24177 $
* $Author: rjongbloed $
* $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $
*/
#ifndef PTLIB_PSOAP_H
#define PTLIB_PSOAP_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#if P_SOAP
#include <ptclib/pxml.h>
#include <ptclib/http.h>
#define DEFAULT_SOAP_URL "/soap"
class PSOAPMessage : public PXML
{
PCLASSINFO(PSOAPMessage, PXML);
public:
PSOAPMessage( int options = PXMLParser::Indent + PXMLParser::NewLineAfterElement );
PSOAPMessage( const PString & method, const PString & nameSpace );
void SetMethod( const PString & name, const PString & nameSpace, const PString & methodPrefix = "m:" );
void GetMethod( PString & name, PString & nameSpace );
void AddParameter( PString name, PString type, PString value );
void AddParameter( PXMLElement* parameter, PBoolean dirty = true );
PBoolean GetParameter( const PString & name, PString & value );
PBoolean GetParameter( const PString & name, int & value );
PXMLElement* GetParameter( const PString & name );
PBoolean Load(const PString & str);
enum
{
NoFault,
VersionMismatch,
MustUnderstand,
Client,
Server
};
PINDEX GetFaultCode() const { return faultCode; }
PString GetFaultText() const { return faultText; }
void SetFault( PINDEX code, const PString & text );
private:
PXMLElement* pSOAPBody;
PXMLElement* pSOAPMethod;
PString faultText;
PINDEX faultCode;
};
class PSOAPServerRequestResponse : public PObject
{
PCLASSINFO( PSOAPServerRequestResponse, PObject );
public:
PSOAPServerRequestResponse( PSOAPMessage & req )
: request( req ) { }
PSOAPMessage & request;
PSOAPMessage response;
};
class PSOAPServerMethod : public PString
{
PCLASSINFO( PSOAPServerMethod, PString );
public:
PSOAPServerMethod( const PString & name )
: PString( name ) { }
PNotifier methodFunc;
};
PSORTED_LIST(PSOAPServerMethodList, PSOAPServerMethod);
class PSOAPServerResource : public PHTTPResource
{
PCLASSINFO( PSOAPServerResource, PHTTPResource );
public:
PSOAPServerResource();
PSOAPServerResource(
const PHTTPAuthority & auth
);
PSOAPServerResource(
const PURL & url
);
PSOAPServerResource(
const PURL & url,
const PHTTPAuthority & auth
);
// overrides from PHTTPResource
PBoolean LoadHeaders( PHTTPRequest & request );
PBoolean OnPOSTData( PHTTPRequest & request, const PStringToString & data );
// new functions
virtual PBoolean OnSOAPRequest( const PString & body, PString & reply );
virtual PBoolean SetMethod( const PString & methodName, const PNotifier & func );
PBoolean OnSOAPRequest( const PString & methodName, PSOAPMessage & request, PString & reply );
virtual PSOAPMessage FormatFault( PINDEX code, const PString & str );
void SetSOAPAction( PString saction ) { soapAction = saction; }
protected:
PMutex methodMutex;
PSOAPServerMethodList methodList;
private:
PString soapAction;
};
class PSOAPClient : public PObject
{
PCLASSINFO( PSOAPClient, PObject );
public:
PSOAPClient( const PURL & url );
void SetTimeout( const PTimeInterval & _timeout ) { timeout = _timeout; }
PBoolean MakeRequest( const PString & method, const PString & nameSpace );
PBoolean MakeRequest( const PString & method, const PString & nameSpace, PSOAPMessage & response );
PBoolean MakeRequest( PSOAPMessage & request, PSOAPMessage & response );
PString GetFaultText() const { return faultText; }
PINDEX GetFaultCode() const { return faultCode; }
void setSOAPAction( PString saction ) { soapAction = saction; }
protected:
PBoolean PerformRequest( PSOAPMessage & request, PSOAPMessage & response );
PURL url;
PINDEX faultCode;
PString faultText;
PTimeInterval timeout;
private:
PString soapAction;
};
#endif // P_SOAP
#endif // PTLIB_PSOAP_H
// End of file ////////////////////////////////////////////////////////////////
PSOAPClient::url
PURL url
Definition: psoap.h:213
PTimeInterval
This class defines an arbitrary time interval to millisecond accuracy.
Definition: timeint.h:55
PSOAPClient::SetTimeout
void SetTimeout(const PTimeInterval &_timeout)
Definition: psoap.h:199
PSOAPServerResource
This resource will bind the methods to an http resource (a url)
Definition: psoap.h:147
PSOAPServerRequestResponse::response
PSOAPMessage response
Definition: psoap.h:128
PCLASSINFO
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:1049
PNotifier
Class specialisation for PNotifierTemplate<INT>
PHTTPAuthority
This abstract class describes the authorisation mechanism for a Universal Resource Locator...
Definition: http.h:1002
PSOAPServerRequestResponse::PSOAPServerRequestResponse
PSOAPServerRequestResponse(PSOAPMessage &req)
Definition: psoap.h:124
PSOAPMessage::MustUnderstand
Error processing SOAP Header field "mustUnderstand".
Definition: psoap.h:97
PSOAPClient
SOAP client classes.
Definition: psoap.h:192
PSOAPMessage::VersionMismatch
Invalid namespace for SOAP Envelope.
Definition: psoap.h:95
PStringToString
This is a dictionary collection class of PString objects, keyed by another string.
Definition: pstring.h:2784
PSOAPMessage::GetFaultText
PString GetFaultText() const
Definition: psoap.h:105
PSOAPMessage::PSOAPMessage
PSOAPMessage(int options=PXMLParser::Indent+PXMLParser::NewLineAfterElement)
Construct a SOAP message.
PSOAPMessage::NoFault
Everything is alright.
Definition: psoap.h:93
PSOAPClient::faultCode
PINDEX faultCode
Definition: psoap.h:214
PHTTPResource
This object describes a HyperText Transport Protocol resource.
Definition: http.h:1222
http.h
PXML
Definition: pxml.h:114
PSOAPServerResource::SetSOAPAction
void SetSOAPAction(PString saction)
Use this method to have the server check for SOAPAction field in HTTP header.
Definition: psoap.h:178
PBoolean
BOOL PBoolean
Definition: object.h:102
PSOAPServerRequestResponse
SOAP Server classes.
Definition: psoap.h:120
PSOAPClient::setSOAPAction
void setSOAPAction(PString saction)
Set a specific SOAPAction field in the HTTTP header, default = " ".
Definition: psoap.h:209
PSOAPServerMethod::PSOAPServerMethod
PSOAPServerMethod(const PString &name)
Definition: psoap.h:137
PSOAPMessage::Load
PBoolean Load(const PString &str)
Parse a string for a valid SOAP message.
PSOAPServerMethod::methodFunc
PNotifier methodFunc
Definition: psoap.h:140
PSOAPMessage::Client
The request was incorrectly formed or did not contain the appropriate information in order to succeed...
Definition: psoap.h:99
PXMLBase::NewLineAfterElement
Definition: pxml.h:74
PString
The character string class.
Definition: pstring.h:108
PSOAPMessage::AddParameter
void AddParameter(PString name, PString type, PString value)
Add a simple parameter called name, with type type and value value.
PSOAPClient::GetFaultCode
PINDEX GetFaultCode() const
Definition: psoap.h:206
PXMLElement
Definition: pxml.h:353
PSORTED_LIST
PSORTED_LIST(PSOAPServerMethodList, PSOAPServerMethod)
PSOAPServerRequestResponse::request
PSOAPMessage & request
Definition: psoap.h:127
PSOAPServerResource::methodMutex
PMutex methodMutex
Definition: psoap.h:181
PSOAPMessage::Server
The request could not be processed for reasons not directly attributable to the contents of the messa...
Definition: psoap.h:101
PSOAPMessage::GetMethod
void GetMethod(PString &name, PString &nameSpace)
Get the method name and namespace.
PSOAPMessage::SetMethod
void SetMethod(const PString &name, const PString &nameSpace, const PString &methodPrefix="m:")
Set the method name and namespace.
PSOAPMessage
SOAP Message classes.
Definition: psoap.h:54
PSOAPMessage::GetParameter
PBoolean GetParameter(const PString &name, PString &value)
Get parameter "name" with type "string".
PSOAPClient::GetFaultText
PString GetFaultText() const
Definition: psoap.h:205
pxml.h
PSOAPClient::faultText
PString faultText
Definition: psoap.h:215
PMutex
Synonym for PTimedMutex.
PSOAPClient::timeout
PTimeInterval timeout
Definition: psoap.h:216
PSOAPServerResource::methodList
PSOAPServerMethodList methodList
Definition: psoap.h:182
PXMLBase::Indent
Definition: pxml.h:73
PSOAPMessage::SetFault
void SetFault(PINDEX code, const PString &text)
PHTTPRequest
This object describes a HyperText Transport Protocol request.
Definition: http.h:968
PObject
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
PURL
This class describes a Universal Resource Locator.
Definition: url.h:54
PSOAPServerMethod
Create an association between a method and its "notifier", the handler function.
Definition: psoap.h:133
PSOAPMessage::GetFaultCode
PINDEX GetFaultCode() const
Definition: psoap.h:104