// WMSOAPProcessor.h: interface for the WMSOAPProcessor class.
//
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2003 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.
//
//////////////////////////////////////////////////////////////////////
//
// WMSOAPProcessor class - implementation of SOAP processor for 'server' side.
//  
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_WMSOAPPROCESSOR_H__73C2C5E8_FD79_4A8F_B92C_FB8F84DAFD4D__INCLUDED_)
#define AFX_WMSOAPPROCESSOR_H__73C2C5E8_FD79_4A8F_B92C_FB8F84DAFD4D__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "WMSOAPHeaderDisp.h"
#include "SOAPAutomationStub.h"
#include "WMXMLMessage.h"
#include "SOAPDIMEHTTPClient.h"

class DIMEParser;
class SOAPSvcDesc;

class WMWebMethodProcessor  
{
public:
    WMWebMethodProcessor()
    {
        m_lSOAPVersion = SOAP_VERSION_1_2;
    }
    virtual ~WMWebMethodProcessor() {}

    long GetSOAPVersion() { return m_lSOAPVersion; }
    void SetSOAPVersion(long lVersion) { m_lSOAPVersion = lVersion; }

protected:

    bool LoadDIMEParser(Iwmsoapmsg2 *pIwmsoapMsg,
                        DIMEParser *pDIMEParser,
                        char *pszOutput,
                        unsigned long ulOutputSize);
    bool UnloadDIMEParser(  Iwmsoapmsg2 *pIwmsoapMsg,
                            DIMEParser *pDIMEParser,
                            SAFEARRAY **ppArray,
                            char **ppszPrimaryPayload,
                            unsigned long& ulPrimaryPayloadSize);

    // SOAP Version
    long        m_lSOAPVersion;

    // from request URI
    wstring     m_wstrSvcURI;
    wstring     m_wstrExtraPath;
    wstring     m_wstrQueryString;

    // header dispatcher
	WMSOAPHeaderDisp		m_HeaderDispatcher;
	// rpc method dispatcher
	WMSOAPAutomationStub	m_AutoStub;
};

class WMSOAPGetProcessor : public WMWebMethodProcessor
{
public:
    WMSOAPGetProcessor() {}
    virtual ~WMSOAPGetProcessor() {}

	int Process( const string& strSvcURI,
                 const string& strExtraPath,
                 const string& strQueryString,
				 IDispatch *pIWSDLParser,
                 SOAPSvcDesc& SvcDescription,
				 char **ppszOutput,
				 unsigned long& ulOutputSize,
				 string& strLogEntry,
				 bool bLoggingEnabled,
                 DIMEParser *pDIMEParser);
protected:

	bool InvokeSoap12GetHandler(const wstring& wstrProgID, Iwmsoapmsg2 *pIwmsoapmsg);
};

class WMSOAPPostProcessor : public WMWebMethodProcessor
{
public:
    WMSOAPPostProcessor() {}
    virtual ~WMSOAPPostProcessor() {}

	int Process( char *pszInputXML,
				 unsigned long ulInputXMLSize,
                 const string& strSvcURI,
                 const string& strExtraPath,
				 IDispatch *pIWSDLParser,
                 SOAPSvcDesc& SvcDescription,
				 const string& strSOAPAction,
				 char **ppszOutput,
				 unsigned long& ulOutputSize,
				 string& strLogEntry,
				 bool bLoggingEnabled,
				 bool bIsDIMERequest,
				 DIMEParser *pDIMEParser);
protected:

	bool InvokeSoap11PostHandler(const wstring& wstrProgID, Iwmsoapmsg2 *pIwmsoapmsg);
	bool InvokeSoap12PostHandler(const wstring& wstrProgID, Iwmsoapmsg2 *pIwmsoapmsg);
    bool CallPostBodyHandlerA(IDispatch *pIDispatch, IDispatch *pIDispatchMsg);
    bool CallPostBodyHandlerB(IDispatch *pIDispatch, IDispatch *pIDispatchMsg);
};

#endif // !defined(AFX_WMSOAPPROCESSOR_H__73C2C5E8_FD79_4A8F_B92C_FB8F84DAFD4D__INCLUDED_)
