Chapter 27: ATL Server FAQ


THIS CHAPTER PRESENTS some of the frequently asked questions (FAQ) we ve received about ATL Server. Many of these questions have been posted on various newsgroups. We ve grouped them here by component. Some of the answers we present direct you to a specific chapter in the book or to articles posted on the Web. We ve tried to keep the answers here as short and concise as possible. Whenever possible, we try to point you to a place where the information we re referring to is presented in more detail.

A few of the solutions we present here involve rewriting/overriding some classes from the library. In such cases, we present the solutions in a more verbose manner; the answers will usually contain instructions detailed down to classes and functions.

Generic ATL Server Application FAQ

The following sections present some generic questions we ve received regarding ATL Server applications.

What Does Assertion in Atlisapi.h, Line 663 Mean?

The ISAPI extension part of ATL Server is responsible for dispatching the requests to the actual request handlers. The call into the actual request handler (which involves execution of the user code) is guarded in a Try Catch block to prevent IIS from crashing in case of an exception. The code that performs this guarding looks like this:

 _ATLTRY  {      (static_cast<IIsapiExtension*>(pvParam))->DispatchStencilCall(pRequestInfo);  }  _ATLCATCHALL()  {      ATLTRACE(_T(        "Warning. An uncaught exception was thrown from DispatchStencilCall\n"));      ATLASSERT(FALSE);  } 

The assertion displayed on the screen is issued by the ATLASSERT line in the preceding code, therefore signaling an exception thrown while processing an HTTP request.

For detailed information on how to troubleshoot such a problem, please refer to Chapter 15.

How Can I Access the Physical Directory of an ATL Server Application?

You have two ways of doing this from a request handler:

  • Call m_HttpRequest.GetScriptPathTranslated() . This is the ISAPI-specific way, using data provided by IIS in the EXTENSION_CONTROL_BLOCK .

  • Call GetModuleFileName and pass CRequestHandlerT::m_hInstHandler as the HINSTANCE parameter.

Now, a SOAP server isn t a CRequestHandlerT derivative. To get the physical path of a SOAP server, you have to override HandleRequest , which is defined in atlsoap.h as follows :

 HTTP_CODE HandleRequest(        AtlServerRequest *pRequestInfo,        IServiceProvider * /*pProvider*/) 

Then invoke pRequestInfo- > pServerContext- > GetScriptPathTranslated .

How Can I Access the Client s SSL Certificate in a Secure Web Application?

According to the ISAPI specification, the ISAPI DLL gets information about client requests by invoking ServerRequestFunction on the extension control block (ECB) pointer received with the request. The HSE_REQ_GET_CERT_INFO_EX server function specifies the certificate context for the first certificate in the client s certificate chain.

Now, assuming the ECB pointer is available ( pECB in the following code snippet), the code for getting access to the client s certificate would look like this:

 char CertificateBuf[8192];  CERT_CONTEXT_EX ccex;  ccex.cbAllocated = sizeof(CertificateBuf);  ccex.CertContext.pbCertEncoded = (BYTE*)CertificateBuf;  DWORD dwSize = sizeof(ccex);  if (pECB->ServerSupportFunction(pECB->ConnID, HSE_REQ_GET_CERT_INFO_EX,     (LPVOID)&ccex, NULL,NULL) == FALSE)  {      // Handle Error Here  }  else  {     // ccex now contains valid client certificate information.  } 

You ll see now how you can retrieve the pointer to the request s ECB. ATL Server preserves the request information in the AtlServerRequest structure in its pECB member. This structure is passed to all the request handlers as a parameter to the HandleRequest method. Therefore, in your implementation of HandleRequest , you could cache the pointer to the AtlServerRequest parameter and then get access to the ECB pointer whenever necessary.

There are two kinds of ATL Server Web applications that, by default, don t override the HandleRequest method: a SOAP server and an application with support for stencil processing. The SOAP FAQ section of this chapter deals with the SOAP server, so we ll focus now on the applications with support for stencil processing.

These applications use classes decorated with the request_handler attribute, which makes them inherit from CHtmlTagReplacer . In its internal implementation of HandleRequest , CHtmlTagReplacer caches the AtlServerRequest parameter (actually, it creates a copy of that parameter). Therefore, you can execute the preceding code for accessing a client s certificate at any time inside the request handler by replacing pECB with m_RequestInfo.pECB .




ATL Server. High Performance C++ on. NET
Observing the User Experience: A Practitioners Guide to User Research
ISBN: B006Z372QQ
EAN: 2147483647
Year: 2002
Pages: 181

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net