You receive an "Access is denied" error message when you try to use the MSXML components from a script on a Pocket PC device that is running Windows Mobile 2003 or Windows Mobile 2003 Second Edition (899125)



The information in this article applies to:

  • Microsoft Windows Mobile 2003 software for Pocket PC
  • Microsoft Windows Mobile 2003 Second Edition software for Pocket PC

SYMPTOMS

On a Pocket PC device, you try to use the Microsoft XML (MSXML) components from a script in an HTML document. When you do this, you may experience the following symptoms:
  • You cannot send XML data to a Web server.
  • You receive an "Access is denied" error message.
For example, if you try to run the following code example, you receive an "Access is denied" error message:
    var objXML = new ActiveXObject( "Microsoft.XMLDOM" );

    objXML.async = false;

    objXML.validateOnParse = false;

    objXML.resolveExternals = false;

    objXML.loadXML( sXML );
You receive the error message when the last statement runs.

This issue occurs when the following conditions are true:
  • You use one of the MSXML Core Services components in Microsoft Windows CE. For example, you use the xmldom component or the xmlhttp component.
  • You access an MSXML component interface by using a scripting language such as Microsoft JScript or JavaScript.
  • You use a Pocket PC device that is running Microsoft Windows Mobile 2003 or Microsoft Windows Mobile 2003 Second Edition.

CAUSE

This issue is caused by a problem with a cross-domain security enhancement that was introduced in Windows CE version 4.2 build 13252 and later builds.

Note Windows Mobile 2003 software for Pocket PC and Windows Mobile 2003 Second Edition software for Pocket PC are based on Windows CE 4.2.

WORKAROUND

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

To work around this issue, create a Component Object Model (COM) adaptor object to act as a proxy when you load the XML document. To do this, follow these steps:
  1. Start Microsoft eMbedded Visual C++ 4.0. Make sure that Service Pack 4 for eMbedded Visual C++ 4.0 is installed.
  2. Create a COM adaptor object that performs the following actions:
    • Internally instantiates the MSXML component
    • Queries for the MSXML component IDispatch interface
    • Returns the MSXML component interface
  3. The following code example illustrates how to define the GetInterface method for the COM adaptor object so that the method returns the interface of an object that is internally instantiated.
    STDMETHODIMP GetInterface
    (
      /*[in]*/ BSTR bstrObj, // Name of the object
      /*[out, retval]*/ VARIANT *pvarObj // Returned object
    )
    {
      CComPtr<IDispatch> pObj;
      IDispatch* pDispatch = NULL;
      HRESULT hr = pObj.CoCreateInstance( bstrObj );
    
      if( SUCCEEDED( hr ) )
      {
        if( pObj )
          hr = pObj->QueryInterface( IID_IDispatch, (void**)&pDispatch );
        else
          hr = E_NOINTERFACE;
      }
    
      VariantClear( pvarObj );
      V_VT( pvarObj ) = VT_DISPATCH;
      V_DISPATCH( pvarObj ) = pDispatch;
    
      return hr;
    }
    
  4. To access the MSXML component interface from a scripting language, follow these steps:
    1. In Notepad, open the file that contains the code.
    2. In the code, create an ActiveX object for the COM adaptor object.
    3. In the code, call the GetInterface method for the COM adaptor object that you created in step 2, and then identify the MSXML component that you want to use. The GetInterface method returns an interface pointer for the MSXML component.
    4. Use the interface pointer in step 4c to access any one of the MSXML component methods.
    The following JScript code example performs the following actions:
    • Creates a COM adaptor object
    • Exposes the interface for the MSXML xmldom component by using the GetInterface method
    • Loads an XML document by calling the loadXML method for the xmldom component
    var objXML = new ActiveXObject("ComAdaptor.ComObject");
    var objRealXML = objXML.GetInterface( "Microsoft.XMLDOM" );	
    objRealXML.async = false;
    objRealXML.validateOnParse = false;
    objRealXML.resolveExternals = false;
    var bLoaded = objRealXML.loadXML(sXML);
    Note You can create similar code for other MSXML components, such as the xmlhttp component.

MORE INFORMATION

A sample COM adaptor is available from the Microsoft Download Center. The following file is available for download from the Microsoft Download Center:
DownloadDownload the COM Adaptor Object.exe package now. Release Date: May 27, 2005

For more information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to obtain Microsoft support files from online services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help prevent any unauthorized changes to the file.

REFERENCES

For more information, click the following article number to view the article in the Microsoft Knowledge Base:

892072 On a Pocket PC, you cannot open the XML document, or the XML document may be blank


Modification Type:MinorLast Reviewed:6/29/2005
Keywords:kbpending kbBug kbtshoot KB899125 kbAudITPRO kbAudDeveloper