I need to call an existing COM+ component into an ATL Web Service. The Generated .IDL file by the OLE/COM Object Viewer of the com+ component is as below.The component was developed in Visual C++ 6
--------------------------
----------
----------
----------
----------
----------
------
// Generated .IDL file (by the OLE/COM Object Viewer)
//
// typelib filename: tmc.dll
[
uuid(57CA9202-5167-402F-B3
66-A850F52
851EB),
version(1.0),
helpstring("tmc 1.0 Type Library")
]
library TMCLib
{
// TLib : // TLib : OLE Automation : {00020430-0000-0000-C000-0
0000000004
6}
importlib("stdole2.tlb");
// Forward declare all types defined in this typelib
interface ITMC_Message;
[
uuid(3EF4595C-C6C0-4CD1-86
BB-B28474A
E6F8F),
helpstring("TMC_Message Class")
]
coclass TMC_Message {
[default] interface ITMC_Message;
};
[
odl,
uuid(9D911DE1-0993-4B5E-B2
AD-EC71551
FEFEA),
helpstring("ITMC_Message Interface"),
dual,
oleautomation
]
interface ITMC_Message : IDispatch {
[id(0x00000001), helpstring("method m_TMCMsgReceive")]
HRESULT m_TMCMsgReceive(
[in, out] BSTR* pbstrTerminalSerialNumberP
aram,
[in, out] long* plEnterpriseIDParam,
[in, out] long* plOperatorIDParam,
[in, out] long* plStoreIDParam,
[in, out] long* plStoreTerminalIDParam,
[in, out] long* plTMCMsgSequenceNumberPara
m,
[in, out] long* plTMCOperatorSessionIDPara
m,
[in, out] long* plTMCMsgTypeParam,
[in, out] VARIANT_BOOL* pfMsgCompressionFlagParam,
[in, out] BSTR* pbstrTerminalVersion,
[in, out] BSTR* pbstrMsgDataBufferParam,
[in, out] BSTR* pbstrMsgReturnBufferParam,
[in, out] long* plErrorReturnCodeParam);
};
};
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
-------
In Visual C++ .Net I have created my ATL Web Service added a reference to COM object and wrote the code below to import the COM+ component into the web service.
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
--------
// TMCSOAWebService.h : Defines the ATL Server request handler class
//
#pragma once
#include <iostream>
#import "C:\Program Files\TMC\tmc.dll" no_namespace
namespace TMCSOAWebServiceService
{
// all struct, enum, and typedefs for your webservice should go inside the namespace
// ITMCSOAWebServiceService - web service interface declaration
//
[
uuid("61768E03-B414-4372-A
CD1-C4ECC0
83AC7A"),
object
]
__interface ITMCSOAWebServiceService
{
// HelloWorld is a sample ATL Server web service method. It shows how to
// declare a web service method and its in-parameters and out-parameters
//[id(1)] HRESULT HelloWorld([in] BSTR bstrInput, [out, retval] BSTR *bstrOutput);
[id(1)] HRESULT TMCMsgReceive(
[in, out] BSTR* pbstrTerminalSerialNumberP
aram,
[in, out] long* plEnterpriseIDParam,
[in, out] long* plOperatorIDParam,
[in, out] long* plStoreIDParam,
[in, out] long* plStoreTerminalIDParam,
[in, out] long* plTMCMsgSequenceNumberPara
m,
[in, out] long* plTMCOperatorSessionIDPara
m,
[in, out] long* plTMCMsgTypeParam,
[in, out] VARIANT_BOOL* pfMsgCompressionFlagParam,
[in, out] BSTR* pbstrTerminalVersion,
[in, out] BSTR* pbstrMsgDataBufferParam,
[in, out] BSTR* pbstrMsgReturnBufferParam,
[in, out] long* plErrorReturnCodeParam);
// TODO: Add additional web service methods here
};
// TMCSOAWebServiceService - web service implementation
//
[
request_handler(name="Defa
ult", sdl="GenTMCSOAWebServiceWS
DL"),
soap_handler(
name="TMCSOAWebServiceServ
ice",
namespace="urn:TMCSOAWebSe
rviceServi
ce",
protocol="soap"
)
]
class CTMCSOAWebServiceService :
public ITMCSOAWebServiceService
{
public:
// uncomment the service declaration(s) if you want to use
// a service that was generated with your ISAPI extension
// CComPtr<IFileCache> m_spFileCache;
// CComPtr<IMemoryCache> m_spBlobCache;
// CComPtr<IBrowserCapsSvc> m_spBrowserCaps;
HTTP_CODE InitializeHandler(AtlServe
rRequest *pRequestInfo, IServiceProvider *pProvider)
{
if (HTTP_SUCCESS != CSoapHandler<CTMCSOAWebSer
viceServic
e>::Initia
lizeHandle
r(pRequest
Info, pProvider))
return HTTP_FAIL;
// Get the IFileCache service from the ISAPI extension
// if (FAILED(pProvider->QuerySe
rvice(__uu
idof(IFile
Cache),
// &m_spFileCache)))
// return HTTP_FAIL;
// Get the IMemoryCache service from the ISAPI extension
// if (FAILED(pProvider->QuerySe
rvice(__uu
idof(IMemo
ryCache),
// &m_spBlobCache)))
// return HTTP_FAIL;
// Uncomment the following code to retrieve a data source
// connection from the data source cache. Replace connection_name
// with a string used to identify the connection and
// connection_string with an OLEDB connection string
// which is valid for your data source. This code assumes that
// the service provider pointed to by m_spServiceProvider
// can provide an IDataSourceCache pointer to a data source
// cache service (usually implemented in the ISAPI extension).
// CDataConnection dc;
// if (S_OK != GetDataSource( pProvider,
// _T("connection_name"),
// L"connection_string",
// &dc ))
// return HTTP_FAIL;
// Get the IBrowserCapsSvc service from the ISAPI extension
// if (FAILED(pProvider->QuerySe
rvice(__uu
idof(IBrow
serCapsSvc
),
// &m_spBrowserCaps)))
// return HTTP_FAIL;
return HTTP_SUCCESS;
}
// This is a sample web service method that shows how to use the
// soap_method attribute to expose a method as a web method
[ soap_method ]
HRESULT TMCMsgReceive( BSTR* pbstrTerminalSerialNumberP
aram,
long* plEnterpriseIDParam,
long* plOperatorIDParam,
long* plStoreIDParam,
long* plStoreTerminalIDParam,
long* plTMCMsgSequenceNumberPara
m,
long* plTMCOperatorSessionIDPara
m,
long* plTMCMsgTypeParam,
VARIANT_BOOL* pfMsgCompressionFlagParam,
BSTR* pbstrTerminalVersion,
BSTR* pbstrMsgDataBufferParam,
BSTR* pbstrMsgReturnBufferParam,
long* plErrorReturnCodeParam)
{
::CoInitialize(NULL);
{
ITMC_Message::m_TMCMsgRece
ive(pbstrT
erminalSer
ialNumberP
aram,
plEnterpriseIDParam,
plOperatorIDParam,
plStoreIDParam,
plStoreTerminalIDParam,
plTMCMsgSequenceNumberPara
m,
plTMCOperatorSessionIDPara
m,
plTMCMsgTypeParam,
pfMsgCompressionFlagParam,
pbstrTerminalVersion,
pbstrMsgDataBufferParam,
pbstrMsgReturnBufferParam,
plErrorReturnCodeParam);
}
::CoUninitialize();
return S_OK;
}
// TODO: Add additional web service methods here
}; // class CTMCSOAWebServiceService
} // namespace TMCSOAWebServiceService
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
--
I am getting the following " error C2352: 'ITMC_Message::m_TMCMsgRec
eive' : illegal call of non-static member function "
I thought possibly the error could be fixed by the hotfix on
http://support.microsoft.com/?kbid=821711. I have installed the hotfix but still getting the same error. I have also tried using the Tlbimp utility but it's failing to open the file in during compilation. Cold some please help ?