Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Temperature Convert:An XML Web service Using ATL Server and MFC Client

, 6 Mar 2007
An XML Web Service using ATL Server and Called by MFC Client
tempconvert.zip
TempConvert
TempConvert.suo
TempConvert
TempConvert.disco
TempConvert.vcproj.ALADDINKING.Administrator.user
TempConvertClient
res
TempConvertClient.ico
temp
results.discomap
TempConvert.wsdl
TempConvertClient.aps
TempConvertClient.vcproj.ALADDINKING.Administrator.user
TempConvertService
results.discomap
TempConvert.wsdl
TempConvertIsapi
TempConvertIsapi.def
TempConvertIsapi.vcproj.ALADDINKING.Administrator.user
tempconvert_binary.zip
TempConvert_Binary
TempConvert
TempConvert.disco
TempConvert.dll
TempConvertIsapi.dll
TempConvertClient_2003
TempConvertClient.exe
TempConvertClient_2005
TempConvertClient.exe
//
// sproxy.exe generated file
// do not modify this file
//
// Created: 03/06/2007@18:13:50
//

#pragma once


#if !defined(_WIN32_WINDOWS) && !defined(_WIN32_WINNT) && !defined(_WIN32_WCE)
#pragma message("warning: defining _WIN32_WINDOWS = 0x0410")
#define _WIN32_WINDOWS 0x0410
#endif

#include <atlsoap.h>

namespace TempConvertService
{

template <typename TClient = CSoapSocketClientT<> >
class CTempConvertServiceT : 
	public TClient, 
	public CSoapRootHandler
{
protected:

	const _soapmap ** GetFunctionMap();
	const _soapmap ** GetHeaderMap();
	void * GetHeaderValue();
	const wchar_t * GetNamespaceUri();
	const char * GetServiceName();
	const char * GetNamespaceUriA();
	HRESULT CallFunction(
		void *pvParam, 
		const wchar_t *wszLocalName, int cchLocalName,
		size_t nItem);
	HRESULT GetClientReader(ISAXXMLReader **ppReader);

public:

	HRESULT __stdcall QueryInterface(REFIID riid, void **ppv)
	{
		if (ppv == NULL)
		{
			return E_POINTER;
		}

		*ppv = NULL;

		if (InlineIsEqualGUID(riid, IID_IUnknown) ||
			InlineIsEqualGUID(riid, IID_ISAXContentHandler))
		{
			*ppv = static_cast<ISAXContentHandler *>(this);
			return S_OK;
		}

		return E_NOINTERFACE;
	}

	ULONG __stdcall AddRef()
	{
		return 1;
	}

	ULONG __stdcall Release()
	{
		return 1;
	}

	CTempConvertServiceT(ISAXXMLReader *pReader = NULL)
		:TClient(_T("http://ws.bomege.com:80/bin/TempConvert.dll\?Handler=Default"))
	{
		SetClient(true);
		SetReader(pReader);
	}
	
	~CTempConvertServiceT()
	{
		Uninitialize();
	}
	
	void Uninitialize()
	{
		UninitializeSOAP();
	}	

	HRESULT ConTempFah2Cel(
		double dFahrenheit, 
		double* __retval
	);

	HRESULT ConTempCel2Fah(
		double dCelsius, 
		double* __retval
	);
};

typedef CTempConvertServiceT<> CTempConvertService;

struct __CTempConvertService_ConTempFah2Cel_struct
{
	double dFahrenheit;
	double __retval;
};

extern __declspec(selectany) const _soapmapentry __CTempConvertService_ConTempFah2Cel_entries[] =
{

	{
		0x8C092922, 
		"dFahrenheit", 
		L"dFahrenheit", 
		sizeof("dFahrenheit")-1, 
		SOAPTYPE_DOUBLE, 
		SOAPFLAG_NONE | SOAPFLAG_IN | SOAPFLAG_RPC | SOAPFLAG_ENCODED,
		offsetof(__CTempConvertService_ConTempFah2Cel_struct, dFahrenheit),
		NULL,
		NULL,
		-1,
	},
	{
		0x11515F60, 
		"return", 
		L"return", 
		sizeof("return")-1, 
		SOAPTYPE_DOUBLE, 
		SOAPFLAG_NONE | SOAPFLAG_OUT | SOAPFLAG_RPC | SOAPFLAG_ENCODED,
		offsetof(__CTempConvertService_ConTempFah2Cel_struct, __retval),
		NULL,
		NULL,
		-1,
	},
	{ 0x00000000 }
};

extern __declspec(selectany) const _soapmap __CTempConvertService_ConTempFah2Cel_map =
{
	0x3B1DDA8B,
	"ConTempFah2Cel",
	L"ConTempFah2Cel",
	sizeof("ConTempFah2Cel")-1,
	sizeof("ConTempFah2Cel")-1,
	SOAPMAP_FUNC,
	__CTempConvertService_ConTempFah2Cel_entries,
	sizeof(__CTempConvertService_ConTempFah2Cel_struct),
	1,
	-1,
	SOAPFLAG_NONE | SOAPFLAG_RPC | SOAPFLAG_ENCODED,
	0xD7B95217,
	"urn:TempConvertService",
	L"urn:TempConvertService",
	sizeof("urn:TempConvertService")-1
};


struct __CTempConvertService_ConTempCel2Fah_struct
{
	double dCelsius;
	double __retval;
};

extern __declspec(selectany) const _soapmapentry __CTempConvertService_ConTempCel2Fah_entries[] =
{

	{
		0x62B14A1C, 
		"dCelsius", 
		L"dCelsius", 
		sizeof("dCelsius")-1, 
		SOAPTYPE_DOUBLE, 
		SOAPFLAG_NONE | SOAPFLAG_IN | SOAPFLAG_RPC | SOAPFLAG_ENCODED,
		offsetof(__CTempConvertService_ConTempCel2Fah_struct, dCelsius),
		NULL,
		NULL,
		-1,
	},
	{
		0x11515F60, 
		"return", 
		L"return", 
		sizeof("return")-1, 
		SOAPTYPE_DOUBLE, 
		SOAPFLAG_NONE | SOAPFLAG_OUT | SOAPFLAG_RPC | SOAPFLAG_ENCODED,
		offsetof(__CTempConvertService_ConTempCel2Fah_struct, __retval),
		NULL,
		NULL,
		-1,
	},
	{ 0x00000000 }
};

extern __declspec(selectany) const _soapmap __CTempConvertService_ConTempCel2Fah_map =
{
	0x5DCC350B,
	"ConTempCel2Fah",
	L"ConTempCel2Fah",
	sizeof("ConTempCel2Fah")-1,
	sizeof("ConTempCel2Fah")-1,
	SOAPMAP_FUNC,
	__CTempConvertService_ConTempCel2Fah_entries,
	sizeof(__CTempConvertService_ConTempCel2Fah_struct),
	1,
	-1,
	SOAPFLAG_NONE | SOAPFLAG_RPC | SOAPFLAG_ENCODED,
	0xD7B95217,
	"urn:TempConvertService",
	L"urn:TempConvertService",
	sizeof("urn:TempConvertService")-1
};

extern __declspec(selectany) const _soapmap * __CTempConvertService_funcs[] =
{
	&__CTempConvertService_ConTempFah2Cel_map,
	&__CTempConvertService_ConTempCel2Fah_map,
	NULL
};

template <typename TClient>
inline HRESULT CTempConvertServiceT<TClient>::ConTempFah2Cel(
		double dFahrenheit, 
		double* __retval
	)
{
    if ( __retval == NULL )
		return E_POINTER;

	HRESULT __atlsoap_hr = InitializeSOAP(NULL);
	if (FAILED(__atlsoap_hr))
	{
		SetClientError(SOAPCLIENT_INITIALIZE_ERROR);
		return __atlsoap_hr;
	}
	
	CleanupClient();

	CComPtr<IStream> __atlsoap_spReadStream;
	__CTempConvertService_ConTempFah2Cel_struct __params;
	memset(&__params, 0x00, sizeof(__params));
	__params.dFahrenheit = dFahrenheit;

	__atlsoap_hr = SetClientStruct(&__params, 0);
	if (FAILED(__atlsoap_hr))
	{
		SetClientError(SOAPCLIENT_OUTOFMEMORY);
		goto __skip_cleanup;
	}
	
	__atlsoap_hr = GenerateResponse(GetWriteStream());
	if (FAILED(__atlsoap_hr))
	{
		SetClientError(SOAPCLIENT_GENERATE_ERROR);
		goto __skip_cleanup;
	}
	
	__atlsoap_hr = SendRequest(_T("SOAPAction: \"#ConTempFah2Cel\"\r\n"));
	if (FAILED(__atlsoap_hr))
	{
		goto __skip_cleanup;
	}
	__atlsoap_hr = GetReadStream(&__atlsoap_spReadStream);
	if (FAILED(__atlsoap_hr))
	{
		SetClientError(SOAPCLIENT_READ_ERROR);
		goto __skip_cleanup;
	}
	
	// cleanup any in/out-params and out-headers from previous calls
	Cleanup();
	__atlsoap_hr = BeginParse(__atlsoap_spReadStream);
	if (FAILED(__atlsoap_hr))
	{
		SetClientError(SOAPCLIENT_PARSE_ERROR);
		goto __cleanup;
	}

	*__retval = __params.__retval;
	goto __skip_cleanup;
	
__cleanup:
	Cleanup();
__skip_cleanup:
	ResetClientState(true);
	memset(&__params, 0x00, sizeof(__params));
	return __atlsoap_hr;
}

template <typename TClient>
inline HRESULT CTempConvertServiceT<TClient>::ConTempCel2Fah(
		double dCelsius, 
		double* __retval
	)
{
    if ( __retval == NULL )
		return E_POINTER;

	HRESULT __atlsoap_hr = InitializeSOAP(NULL);
	if (FAILED(__atlsoap_hr))
	{
		SetClientError(SOAPCLIENT_INITIALIZE_ERROR);
		return __atlsoap_hr;
	}
	
	CleanupClient();

	CComPtr<IStream> __atlsoap_spReadStream;
	__CTempConvertService_ConTempCel2Fah_struct __params;
	memset(&__params, 0x00, sizeof(__params));
	__params.dCelsius = dCelsius;

	__atlsoap_hr = SetClientStruct(&__params, 1);
	if (FAILED(__atlsoap_hr))
	{
		SetClientError(SOAPCLIENT_OUTOFMEMORY);
		goto __skip_cleanup;
	}
	
	__atlsoap_hr = GenerateResponse(GetWriteStream());
	if (FAILED(__atlsoap_hr))
	{
		SetClientError(SOAPCLIENT_GENERATE_ERROR);
		goto __skip_cleanup;
	}
	
	__atlsoap_hr = SendRequest(_T("SOAPAction: \"#ConTempCel2Fah\"\r\n"));
	if (FAILED(__atlsoap_hr))
	{
		goto __skip_cleanup;
	}
	__atlsoap_hr = GetReadStream(&__atlsoap_spReadStream);
	if (FAILED(__atlsoap_hr))
	{
		SetClientError(SOAPCLIENT_READ_ERROR);
		goto __skip_cleanup;
	}
	
	// cleanup any in/out-params and out-headers from previous calls
	Cleanup();
	__atlsoap_hr = BeginParse(__atlsoap_spReadStream);
	if (FAILED(__atlsoap_hr))
	{
		SetClientError(SOAPCLIENT_PARSE_ERROR);
		goto __cleanup;
	}

	*__retval = __params.__retval;
	goto __skip_cleanup;
	
__cleanup:
	Cleanup();
__skip_cleanup:
	ResetClientState(true);
	memset(&__params, 0x00, sizeof(__params));
	return __atlsoap_hr;
}

template <typename TClient>
ATL_NOINLINE inline const _soapmap ** CTempConvertServiceT<TClient>::GetFunctionMap()
{
	return __CTempConvertService_funcs;
}

template <typename TClient>
ATL_NOINLINE inline const _soapmap ** CTempConvertServiceT<TClient>::GetHeaderMap()
{
	static const _soapmapentry __CTempConvertService_ConTempFah2Cel_atlsoapheader_entries[] =
	{
		{ 0x00000000 }
	};

	static const _soapmap __CTempConvertService_ConTempFah2Cel_atlsoapheader_map = 
	{
		0x3B1DDA8B,
		"ConTempFah2Cel",
		L"ConTempFah2Cel",
		sizeof("ConTempFah2Cel")-1,
		sizeof("ConTempFah2Cel")-1,
		SOAPMAP_HEADER,
		__CTempConvertService_ConTempFah2Cel_atlsoapheader_entries,
		0,
		0,
		-1,
		SOAPFLAG_NONE | SOAPFLAG_RPC | SOAPFLAG_ENCODED,
		0xD7B95217,
		"urn:TempConvertService",
		L"urn:TempConvertService",
		sizeof("urn:TempConvertService")-1
	};

	static const _soapmapentry __CTempConvertService_ConTempCel2Fah_atlsoapheader_entries[] =
	{
		{ 0x00000000 }
	};

	static const _soapmap __CTempConvertService_ConTempCel2Fah_atlsoapheader_map = 
	{
		0x5DCC350B,
		"ConTempCel2Fah",
		L"ConTempCel2Fah",
		sizeof("ConTempCel2Fah")-1,
		sizeof("ConTempCel2Fah")-1,
		SOAPMAP_HEADER,
		__CTempConvertService_ConTempCel2Fah_atlsoapheader_entries,
		0,
		0,
		-1,
		SOAPFLAG_NONE | SOAPFLAG_RPC | SOAPFLAG_ENCODED,
		0xD7B95217,
		"urn:TempConvertService",
		L"urn:TempConvertService",
		sizeof("urn:TempConvertService")-1
	};


	static const _soapmap * __CTempConvertService_headers[] =
	{
		&__CTempConvertService_ConTempFah2Cel_atlsoapheader_map,
		&__CTempConvertService_ConTempCel2Fah_atlsoapheader_map,
		NULL
	};
	
	return __CTempConvertService_headers;
}

template <typename TClient>
ATL_NOINLINE inline void * CTempConvertServiceT<TClient>::GetHeaderValue()
{
	return this;
}

template <typename TClient>
ATL_NOINLINE inline const wchar_t * CTempConvertServiceT<TClient>::GetNamespaceUri()
{
	return L"urn:TempConvertService";
}

template <typename TClient>
ATL_NOINLINE inline const char * CTempConvertServiceT<TClient>::GetServiceName()
{
	return NULL;
}

template <typename TClient>
ATL_NOINLINE inline const char * CTempConvertServiceT<TClient>::GetNamespaceUriA()
{
	return "urn:TempConvertService";
}

template <typename TClient>
ATL_NOINLINE inline HRESULT CTempConvertServiceT<TClient>::CallFunction(
	void *, 
	const wchar_t *, int,
	size_t)
{
	return E_NOTIMPL;
}

template <typename TClient>
ATL_NOINLINE inline HRESULT CTempConvertServiceT<TClient>::GetClientReader(ISAXXMLReader **ppReader)
{
	if (ppReader == NULL)
	{
		return E_INVALIDARG;
	}
	
	CComPtr<ISAXXMLReader> spReader = GetReader();
	if (spReader.p != NULL)
	{
		*ppReader = spReader.Detach();
		return S_OK;
	}
	return TClient::GetClientReader(ppReader);
}

} // namespace TempConvertService

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

James, Lu Zuheng
Web Developer
China China
I am favor to use C\C++,MFC,ATL,COM and JavaScript to program, and interesting in network security as well.In my spare time,I like playingbasketball,Climbing.I now live in Beijing,China.It is nice to go along the red walls around the Forbitten City.

| Advertise | Privacy | Mobile
Web01 | 2.8.141015.1 | Last Updated 6 Mar 2007
Article Copyright 2007 by James, Lu Zuheng
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid