NCBI C++ ToolKit
soap_message.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef SOAP_MESSAGE__HPP
2 #define SOAP_MESSAGE__HPP
3 
4 /* $Id: soap_message.hpp 54984 2012-06-29 14:22:29Z ivanov $
5 * ===========================================================================
6 *
7 * PUBLIC DOMAIN NOTICE
8 * National Center for Biotechnology Information
9 *
10 * This software/database is a "United States Government Work" under the
11 * terms of the United States Copyright Act. It was written as part of
12 * the author's official duties as a United States Government employee and
13 * thus cannot be copyrighted. This software/database is freely available
14 * to the public for use. The National Library of Medicine and the U.S.
15 * Government have not placed any restriction on its use or reproduction.
16 *
17 * Although all reasonable efforts have been taken to ensure the accuracy
18 * and reliability of the software and data, the NLM and the U.S.
19 * Government do not and cannot warrant the performance or results that
20 * may be obtained by using this software or data. The NLM and the U.S.
21 * Government disclaim all warranties, express or implied, including
22 * warranties of performance, merchantability or fitness for any particular
23 * purpose.
24 *
25 * Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * Author: Andrei Gourianov
30 *
31 * File Description:
32 * Hold the content of, send and receive SOAP messages
33 */
34 
35 #include <serial/serialbase.hpp>
37 
39 
40 class CSoapMessage : public CObject
41 {
42 public:
43  CSoapMessage(void);
44  CSoapMessage(const string& namespace_name);
45  ~CSoapMessage(void);
46 
47  typedef vector< CConstRef<CSerialObject> > TSoapContent;
48 
49  enum EMessagePart {
53  };
54 
55 // attributes
56  static const string GetSoapNamespace(void);
57  void SetSoapNamespacePrefix(const string& prefix);
58  const string& GetSoapNamespacePrefix(void) const;
59 
60  void SetDefaultObjectNamespaceName(const string& ns_name);
61  const string& GetDefaultObjectNamespaceName(void) const;
62 
63 // writing
64  void AddObject(const CSerialObject& obj, EMessagePart destination);
65  void Write(CObjectOStream& out) const;
66 
67 // reading
68  void RegisterObjectType(TTypeInfoGetter type_getter);
69  void RegisterObjectType(const CTypeInfo& type);
70  void RegisterObjectType(const CSerialObject& obj);
71 
72  void Read(CObjectIStream& in);
73 
74 // data access
75  void Reset(void);
76 
77  const TSoapContent& GetContent(EMessagePart source) const;
78  CConstRef<CSerialObject> GetSerialObject(const string& type_name,
79  EMessagePart source) const;
81  EMessagePart source) const;
82 
83 
85  {
86  return m_Fault;
87  }
88 
89 private:
90  void x_Check(const CSoapEnvelope& env);
91  void x_VerifyFaultObj(bool add_prefix) const;
92 
94  string m_Prefix;
96  TSoapContent m_Header;
97  TSoapContent m_Body;
98  TSoapContent m_FaultDetail;
99  vector< const CTypeInfo* > m_Types;
100 
101  static const char* ms_SoapNamespace;
102 };
103 
104 inline
106 {
107  object.Write(out);
108  return out;
109 }
110 
111 inline
113 {
114  object.Read(in);
115  return in;
116 }
117 
118 template <typename TObj>
121 {
123  TObj::GetTypeInfo()->GetName(),source);
124  return CConstRef<TObj>( dynamic_cast<const TObj*>(oo.GetPointer()));
125 }
126 
128 
129 #endif /* SOAP_MESSAGE__HPP */
const TSoapContent & GetContent(EMessagePart source) const
CConstRef< TObj > SOAP_GetKnownObject(const CSoapMessage &msg, CSoapMessage::EMessagePart source=CSoapMessage::eMsgBody)
CObjectIStream –.
Definition: objistr.hpp:92
void Read(CObjectIStream &in)
~CSoapMessage(void)
void SetDefaultObjectNamespaceName(const string &ns_name)
std::ofstream out("events_result.xml")
main entry point for tests
TSoapContent m_Body
void AddObject(const CSerialObject &obj, EMessagePart destination)
CObjectOStream –.
Definition: objostr.hpp:82
void Write(const CConstObjectInfo &object)
Definition: objostr.cpp:577
void x_VerifyFaultObj(bool add_prefix) const
vector< const CTypeInfo * > m_Types
void x_Check(const CSoapEnvelope &env)
CSoapFault::ESoap_FaultcodeEnum GetFaultCode(void) const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:101
CObjectOStream & operator<<(CObjectOStream &out, const CSoapMessage &object)
vector< CConstRef< CSerialObject > > TSoapContent
TTypeInfo(* TTypeInfoGetter)(void)
Definition: serialdef.hpp:63
CConstRef< CSerialObject > GetSerialObject(const string &type_name, EMessagePart source) const
Definition: type.c:8
CConstRef< CAnyContentObject > GetAnyContentObject(const string &name, EMessagePart source) const
const CharType(& source)[N]
Definition: pointer.h:1107
void RegisterObjectType(TTypeInfoGetter type_getter)
string m_DefNamespaceName
const string & GetDefaultObjectNamespaceName(void) const
void Write(CObjectOStream &out) const
static const char * ms_SoapNamespace
static const string GetSoapNamespace(void)
TSoapContent m_FaultDetail
void SetSoapNamespacePrefix(const string &prefix)
Base class for all serializable objects.
Definition: serialbase.hpp:148
CObject –.
Definition: ncbiobj.hpp:180
CSoapMessage(void)
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Definition: typeinfo.hpp:74
TObjectType * GetPointer(void) const THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:1564
TSoapContent m_Header
CObjectIStream & operator>>(CObjectIStream &in, CSoapMessage &object)
CSoapFault::ESoap_FaultcodeEnum m_Fault
static const char * prefix[]
Definition: pcregrep.c:251
void Reset(void)
std::istream & in(std::istream &in_, double &x_)
static HENV env
Definition: transaction2.c:41
void Read(const CObjectInfo &object)
Read object of know type.
Definition: objistr.cpp:923
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:98
const string & GetSoapNamespacePrefix(void) const
Modified on Wed Jun 29 18:25:43 2016 by modify_doxy.py rev. 426318