Discussion:
isapi filter and com objects
(too old to reply)
Aintzane
2004-12-15 11:52:06 UTC
Permalink
Hi, we're developing an ISAPI Filter and we're having problems. We
have been given an ATL COM object which is running in a server. Our
ISAPI Filter is going to run in the same server.

In the filter we call a function of the object which returns a pointer
which will be an XML document. This is the part of our code that
doesn't work properly:


APISESIONLib::Inapisesion * pApiSesion;
HRESULT hr = NULL;
MSXML::IXMLDOMDocument * pDoc = NULL;
struct IDispatch* sid = NULL;
BSTR szIP = XXXX; (an IP address)
BSTR bstr;

CoInitialize (NULL);
hr = CoCreateInstance (APISESIONLib::CLSID_apisesion, NULL,
CLSCTX_SERVER, APISESIONLib::IID_Inapisesion, (void **)&pApiSesion);
hr = pApiSesion->raw_APISesionResolverDominio (szIP, &sid);
CoUninitialize();
pDoc = (MSXML::IXMLDOMDocument *)sid;
pDoc->get_xml (&bstr);


What happens is the following. The function CoCreateInstance works
well, it returns hr = S_OK. The function
"raw_APISesionResolverDominio" of the APISesion object works well too,
we have tested that before returning from the object, the "sid"
parameter contains a correct XML document. The returned parameter
"sid" is not null, but after "get_xml" function "bstr" is empty

We don't know what is happening. Is there something missed or wrong in
this code? Thanks in advance.

Aintzane
r***@hotmail.com
2004-12-16 06:47:12 UTC
Permalink
Your problem appears that you are calling CoUnitialize() prior to
calling the method get_xml().

In otherwords, you are shutting down COM on the given thread before you
are attempting to get the bstr with the get_xml() method.

In the future, if you run into a problem like this, it might also help
to check the HRESULT from the get_xml() call. Often times COM will
provide you with an error code that will help you determine the cause
of the problem.

Warmest Regards,

Michael Loritsch

Loading...