Microsoft KB Archive/899125

= You receive an &quot;Access is denied&quot; 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 =

Article ID: 899125

Article Last Modified on 6/29/2005

-

APPLIES TO


 * Microsoft Windows Mobile 2003 software for Pocket PC Standard Edition
 * Microsoft Windows Mobile 2003 software for Pocket PC Standard Edition

-





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 &quot;Access is denied&quot; error message.

For example, if you try to run the following code example, you receive an &quot;Access is denied&quot; error message: var objXML = new ActiveXObject( &quot;Microsoft.XMLDOM&quot; );

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:  Start Microsoft eMbedded Visual C++ 4.0. Make sure that Service Pack 4 for eMbedded Visual C++ 4.0 is installed. 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 </li>  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; } </li>  To access the MSXML component interface from a scripting language, follow these steps: <ol style="list-style-type: lower-alpha;"> In Notepad, open the file that contains the code.</li> In the code, create an ActiveX object for the COM adaptor object.</li> 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.</li> Use the interface pointer in step 4c to access any one of the MSXML component methods.</li></ol>

The following JScript code example performs the following actions:  Creates a COM adaptor object</li> Exposes the interface for the MSXML xmldom component by using the GetInterface method</li> Loads an XML document by calling the loadXML method for the xmldom component</li></ul>

var objXML = new ActiveXObject(&quot;ComAdaptor.ComObject&quot;); var objRealXML = objXML.GetInterface( &quot;Microsoft.XMLDOM&quot; ); 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. </li></ol>

<div class="moreinformation_section">

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:

Download 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.

<div class="references_section">