[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.4

importing existing COM+ component into an ATL Web Service

Asked by Code_Angel in Microsoft Visual C++.Net, Microsoft Programming

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-B366-A850F52851EB),
  version(1.0),
  helpstring("tmc 1.0 Type Library")
]
library TMCLib
{
    // TLib :     // TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
    importlib("stdole2.tlb");

    // Forward declare all types defined in this typelib
    interface ITMC_Message;

    [
      uuid(3EF4595C-C6C0-4CD1-86BB-B28474AE6F8F),
      helpstring("TMC_Message Class")
    ]
    coclass TMC_Message {
        [default] interface ITMC_Message;
    };

    [
      odl,
      uuid(9D911DE1-0993-4B5E-B2AD-EC71551FEFEA),
      helpstring("ITMC_Message Interface"),
      dual,
      oleautomation
    ]
    interface ITMC_Message : IDispatch {
        [id(0x00000001), helpstring("method m_TMCMsgReceive")]
        HRESULT m_TMCMsgReceive(
                        [in, out] BSTR* pbstrTerminalSerialNumberParam,
                        [in, out] long* plEnterpriseIDParam,
                        [in, out] long* plOperatorIDParam,
                        [in, out] long* plStoreIDParam,
                        [in, out] long* plStoreTerminalIDParam,
                        [in, out] long* plTMCMsgSequenceNumberParam,
                        [in, out] long* plTMCOperatorSessionIDParam,
                        [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-ACD1-C4ECC083AC7A"),
      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* pbstrTerminalSerialNumberParam,
                [in, out] long* plEnterpriseIDParam,
                [in, out] long* plOperatorIDParam,
                [in, out] long* plStoreIDParam,
                [in, out] long* plStoreTerminalIDParam,
                [in, out] long* plTMCMsgSequenceNumberParam,
                [in, out] long* plTMCOperatorSessionIDParam,
                [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="Default", sdl="GenTMCSOAWebServiceWSDL"),
      soap_handler(
            name="TMCSOAWebServiceService",
            namespace="urn:TMCSOAWebServiceService",
            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(AtlServerRequest *pRequestInfo, IServiceProvider *pProvider)
      {
            if (HTTP_SUCCESS != CSoapHandler<CTMCSOAWebServiceService>::InitializeHandler(pRequestInfo, pProvider))
                  return HTTP_FAIL;

            // Get the IFileCache service from the ISAPI extension
//            if (FAILED(pProvider->QueryService(__uuidof(IFileCache),
//                                    &m_spFileCache)))
//                  return HTTP_FAIL;

            // Get the IMemoryCache service from the ISAPI extension
//            if (FAILED(pProvider->QueryService(__uuidof(IMemoryCache),
//                                    &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->QueryService(__uuidof(IBrowserCapsSvc),
//                                    &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* pbstrTerminalSerialNumberParam,
                                          long* plEnterpriseIDParam,
                                          long* plOperatorIDParam,
                                          long* plStoreIDParam,
                                          long* plStoreTerminalIDParam,
                                          long* plTMCMsgSequenceNumberParam,
                                          long* plTMCOperatorSessionIDParam,
                                          long* plTMCMsgTypeParam,
                                         VARIANT_BOOL* pfMsgCompressionFlagParam,
                                         BSTR* pbstrTerminalVersion,
                                         BSTR* pbstrMsgDataBufferParam,
                                         BSTR* pbstrMsgReturnBufferParam,
                                        long* plErrorReturnCodeParam)

      {
            ::CoInitialize(NULL);
            {
            ITMC_Message::m_TMCMsgReceive(pbstrTerminalSerialNumberParam,
                                      plEnterpriseIDParam,
                                      plOperatorIDParam,
                                      plStoreIDParam,
                                      plStoreTerminalIDParam,
                                      plTMCMsgSequenceNumberParam,
                                      plTMCOperatorSessionIDParam,
                                      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_TMCMsgReceive' : 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 ?
[+][-]01/10/05 08:28 AM, ID: 13004321Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Microsoft Visual C++.Net, Microsoft Programming
Sign Up Now!
Solution Provided By: drichards
Participating Experts: 1
Solution Grade: A
 
[+][-]01/10/05 10:27 AM, ID: 13005786Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/13/05 02:43 PM, ID: 13299969Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]02/17/05 04:55 AM, ID: 13334088Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81