// SoapDocMessage.h
//
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002 Robert Cunnings. All rights reserved.
//
// You may copy, modify, distribute or publish this code free of charge.
//
// NO WARRANTY: This software is provided AS IS, without warranty of any kind.
//
//////////////////////////////////////////////////////////////////////
//
// WMSOAPDocMessage class - a class representing a SOAP message
// using the "document/literal" convention. For use by client code.
// 
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_SOAPDOCMESSAGE_H__CE664AFE_9841_4FCF_9368_37A155603AB9__INCLUDED_)
#define AFX_SOAPDOCMESSAGE_H__CE664AFE_9841_4FCF_9368_37A155603AB9__INCLUDED_

#include "XMLDocFragment.h"

class WMXMLElement;

class WMSOAPDocMessage : public WMXMLDocFragment
{
public:
    WMSOAPDocMessage(void);
    ~WMSOAPDocMessage(void);

    bool Serialize(string& strXML, int nSOAPVersion);
    bool Serialize(wstring& wstrXML, int nSOAPVersion);
    bool Serialize(BSTR *pbstrXML, int nSOAPVersion);
    bool Deserialize(const string& strXML);
    bool Deserialize(const wstring& wstrXML);
    bool Deserialize(const BSTR bstrXML);

    int GetSOAPVersion() { return m_nSOAPVersion; }
    void SetSOAPVersion(int nSOAPVersion) { m_nSOAPVersion = nSOAPVersion; }

    bool AddHeaderEntry(WMXMLElement *pElem);
    bool AddBodyEntry(WMXMLElement *pElem);

    WMXMLElement *CreateHeaderEntry(const wstring& wstrNamespace,
                                    const wstring& wstrPrefix,
                                    const wstring& wstrLocalName,
                                    const wstring& wstrRole,
                                    bool bIsMustUnderstand);
    WMXMLElement *CreateBodyEntry(  const wstring& wstrNamespace,
                                    const wstring& wstrPrefix,
                                    const wstring& wstrLocalName);

    // retrieval from received message
    WMXMLElement *GetHeaderEntry(   const wstring& wstrNamespace,
                                    const wstring& wstrName);
    WMXMLElement *GetBodyEntry( const wstring& wstrNamespace,
                                const wstring& wstrName);

    WMXMLElement *GetFaultMsg();
    bool GetSOAPFaultCode(wstring& wstrValueNS, wstring& wstrValue);
    bool GetSOAPFaultString(wstring& wstrValue);
    WMXMLElement *GetSOAPFaultDetail(   const wstring& wstrNamespace,
                                        const wstring& wstrName);

protected:

    WMXMLElement *BuildSOAPMsg(int nSOAPVersion);

    // SOAP version
    int                                 m_nSOAPVersion;
    // header entries
    list<WMXMLElement *>                m_listHeaderEntries;
    // body entries
    list<WMXMLElement *>                m_listBodyEntries;
};

#endif // !defined(AFX_SOAPDOCMESSAGE_H__CE664AFE_9841_4FCF_9368_37A155603AB9__INCLUDED_)
