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.
CAUSEThis 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.WORKAROUNDMicrosoft 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
- 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;
}
- To access the MSXML component interface from a scripting
language, follow these steps:
- In Notepad, open the file that contains the code.
- In the code, create an ActiveX object for the
COM adaptor object.
- 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.
- 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.
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: | Minor | Last Reviewed: | 6/29/2005 |
---|
Keywords: | kbpending kbBug kbtshoot KB899125 kbAudITPRO kbAudDeveloper |
---|
|