RE: XMLHTTP doesn't work, I'm getting access denied by a-nlewis
a-nlewis
Fri Feb 18 17:07:54 CST 2005
------=_NextPart_0001_31C96BB2
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
The JScript code will work correctly as shown. The "[out, retval]"
declaration specifies that the function will return the object directly.
If you wanted to access the HRESULT return value, you would have to do that
directly from a language such as C++. Please give it a try, and you will
see what I mean.
---
Nathan Lewis
Microsoft Mobile and Embedded Devices Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: =?Utf-8?B?V29ya2luZyB3aXRoIFNsb21p?= <Working with
Slomi@discussions.microsoft.com>
Subject: RE: XMLHTTP doesn't work, I'm getting access denied
Date: Fri, 18 Feb 2005 04:19:01 -0800
Hi Mr. leweis.
I read your answer - but it's not complete, it is dealing only in one
aspect
in the problem.
Ok, so we don't need to send the second parameter in the java script,
but in this parameter the reference to the object is should be returned.
so how there is a way to retrieve the object pointer???
the methods itself return an HRESULT type, which is actually a long.
how can we get the reference to the object that has been created in
GetInterface() method.
Example:
You gave us this code for using the object:
var objXML = new ActiveXObject( "ComAdapter.ComObject" );
var objRealXML = objXML.GetInterface( "Microsoft.XMLHTTP" );
In your example the objRealXML variable will hold a reference to the
"Microsoft.XMLHTTP" COM object, but the return value of the GetInterface()
is HRESULT , as declared in the idl file:
HRESULT GetInterface( [in] BSTR bstrObj, [out, retval] VARIANT*
pvarObj );
How can we get the VARIANT* pvarObj , which hold the reference to the
"Microsoft.XMLHTTP" COM object, from a Java Script code.
Thanks for your support,
Eli
"Nathan Lewis" wrote:
> If you specified the second parameter in the IDL using [out, retval],
then
> you will only need one parameter in the JScript code. The correct IDL
> definition would be something like:
>
> [
> object,
> uuid( ...your GUID here... ),
> dual,
> helpstring("IComObject Interface"),
> pointer_default(unique)
> ]
> interface IComObject : IDispatch
> {
> [
> id(1),
> helpstring("Returns the requested object interface.")
> ]
> HRESULT GetInterface( [in] BSTR bstrObj, [out, retval] VARIANT*
> pvarObj );
> };
>
>
> I'm not sure if there are plans to create a sample for this workaround,
but
> a KB has been requested.
>
>
> ---
>
> Nathan Lewis
> Microsoft Mobile and Embedded Devices Developer Support
>
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>
>
>
> --------------------
> From: =?Utf-8?B?U2hsb21p?= <Shlomi@discussions.microsoft.com>
> Subject: RE: XMLHTTP doesn't work, I'm getting access denied
> Date: Thu, 17 Feb 2005 03:15:01 -0800
>
>
> I'm trying to implement your solution, I've created the dll and loaded it
> to
> the iPaq, I'm getting an error from Javascript for sending the wrong
number
> of parameters for the GetInterface method. From what I understand
> GetInterface should return the object in pvarObj, who do I use that in
> Javascript?
>
> Does Microsoft intend to distribute a solution for this problem?
>
> "Nathan Lewis" wrote:
>
> > This is a known problem which affects certain builds of Pocket PC 2003
> and
> > all builds of Pocket PC 2003 Second Edition. The workaround is pretty
> > complicated, and involves creating an ActiveX control using ATL and
> > embedding it in the web page. Other than the complexity of the
> workaround,
> > the main disadvantage to this approach is that it means your end users
> must
> > download, install and register the ActiveX control before they can use
> your
> > HTML content. Unfortunately, there is no other way around the problem.
> >
> > If you are familiar with creating ATL controls, the process is pretty
> > straightforward. Start by creating an ATL project and add a simple
> object
> > to it - let's call the control "ComAdapter" and the object "ComObject".
> > Then add the following method to the object:
> >
> > 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;
> > }
> >
> > Finally, you will need to make some changes to your HTML code -
something
> > like this:
> >
> > var objXML = new ActiveXObject( "ComAdapter.ComObject" );
> > var objRealXML = objXML.GetInterface( "Microsoft.XMLHTTP" );
> > objRealXML.open( "POST", url, true );
> >
> >
> > ---
> >
> > Nathan Lewis
> > Microsoft Mobile and Embedded Devices Developer Support
> >
> > This posting is provided "AS IS" with no warranties, and confers no
> rights.
> >
> >
> >
> > --------------------
> > From: =?Utf-8?B?U2hsb21p?= <Shlomi@discussions.microsoft.com>
> > Subject: XMLHTTP doesn't work, I'm getting access denied
> > Date: Wed, 16 Feb 2005 05:19:03 -0800
> >
> >
> > Hello,
> >
> > I need to write a web application for my pocket PC, here is part of
the
> > code I'm using:
> >
> > xrequest = new ActiveXObject("Microsoft.XMLHTTP");
> > xrequest.open("POST",url,true );
> >
> > I'm getting access denied when trying to execute the open method.
> >
> > The same code works fine when running it using scripting host on the
same
> > pocket PC. Also, the same code works fine on another iPaq I have that
> uses
> > win CE 4
> >
> > Trying to change the security setting in the registry didn't help.
> >
> > Can someone please help
> >
> > Thanks,
> > Shlomi
> >
> >
>
------=_NextPart_0001_31C96BB2
Content-Type: text/x-rtf
Content-Transfer-Encoding: 7bit
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fprq2\fcharset0 MS Sans Serif;}}
\viewkind4\uc1\pard\f0\fs20 The JScript code will work correctly as shown. The "[out, retval]" declaration specifies that the function will return the object directly. If you wanted to access the HRESULT return value, you would have to do that directly from a language such as C++. Please give it a try, and you will see what I mean.
\par
\par
\par ---
\par
\par Nathan Lewis
\par Microsoft Mobile and Embedded Devices Developer Support
\par
\par This posting is provided "AS IS" with no warranties, and confers no rights.
\par
\par
\par
\par \pard\li720 --------------------
\par From: =?Utf-8?B?V29ya2luZyB3aXRoIFNsb21p?= <Working with Slomi@discussions.microsoft.com>
\par Subject: RE: XMLHTTP doesn't work, I'm getting access denied
\par Date: Fri, 18 Feb 2005 04:19:01 -0800
\par
\par
\par Hi Mr. leweis.
\par
\par
\par I read your answer - but it's not complete, it is dealing only in one aspect
\par in the problem.
\par
\par Ok, so we don't need to send the second parameter in the java script,
\par
\par but in this parameter the reference to the object is should be returned.
\par
\par so how there is a way to retrieve the object pointer???
\par
\par the methods itself return an HRESULT type, which is actually a long.
\par
\par how can we get the reference to the object that has been created in
\par GetInterface() method.
\par
\par
\par Example:
\par
\par You gave us this code for using the object:
\par
\par var objXML = new ActiveXObject( "ComAdapter.ComObject" );
\par var objRealXML = objXML.GetInterface( "Microsoft.XMLHTTP" );
\par
\par
\par In your example the objRealXML variable will hold a reference to the
\par "Microsoft.XMLHTTP" COM object, but the return value of the GetInterface()
\par is HRESULT , as declared in the idl file:
\par
\par HRESULT GetInterface( [in] BSTR bstrObj, [out, retval] VARIANT*
\par pvarObj );
\par
\par
\par How can we get the VARIANT* pvarObj , which hold the reference to the
\par "Microsoft.XMLHTTP" COM object, from a Java Script code.
\par
\par Thanks for your support,
\par
\par Eli
\par
\par
\par
\par "Nathan Lewis" wrote:
\par
\par > If you specified the second parameter in the IDL using [out, retval], then
\par > you will only need one parameter in the JScript code. The correct IDL
\par > definition would be something like:
\par >
\par > [
\par > object,
\par > uuid( ...your GUID here... ),
\par > dual,
\par > helpstring("IComObject Interface"),
\par > pointer_default(unique)
\par > ]
\par > interface IComObject : IDispatch
\par > \{
\par > [
\par > id(1),
\par > helpstring("Returns the requested object interface.")
\par > ]
\par > HRESULT GetInterface( [in] BSTR bstrObj, [out, retval] VARIANT*
\par > pvarObj );
\par > \};
\par >
\par >
\par > I'm not sure if there are plans to create a sample for this workaround, but
\par > a KB has been requested.
\par >
\par >
\par > ---
\par >
\par > Nathan Lewis
\par > Microsoft Mobile and Embedded Devices Developer Support
\par >
\par > This posting is provided "AS IS" with no warranties, and confers no rights.
\par >
\par >
\par >
\par > --------------------
\par > From: =?Utf-8?B?U2hsb21p?= <Shlomi@discussions.microsoft.com>
\par > Subject: RE: XMLHTTP doesn't work, I'm getting access denied
\par > Date: Thu, 17 Feb 2005 03:15:01 -0800
\par >
\par >
\par > I'm trying to implement your solution, I've created the dll and loaded it
\par > to
\par > the iPaq, I'm getting an error from Javascript for sending the wrong number
\par > of parameters for the GetInterface method. From what I understand
\par > GetInterface should return the object in pvarObj, who do I use that in
\par > Javascript?
\par >
\par > Does Microsoft intend to distribute a solution for this problem?
\par >
\par > "Nathan Lewis" wrote:
\par >
\par > > This is a known problem which affects certain builds of Pocket PC 2003
\par > and
\par > > all builds of Pocket PC 2003 Second Edition. The workaround is pretty
\par > > complicated, and involves creating an ActiveX control using ATL and
\par > > embedding it in the web page. Other than the complexity of the
\par > workaround,
\par > > the main disadvantage to this approach is that it means your end users
\par > must
\par > > download, install and register the ActiveX control before they can use
\par > your
\par > > HTML content. Unfortunately, there is no other way around the problem.
\par > >
\par > > If you are familiar with creating ATL controls, the process is pretty
\par > > straightforward. Start by creating an ATL project and add a simple
\par > object
\par > > to it - let's call the control "ComAdapter" and the object "ComObject".
\par > > Then add the following method to the object:
\par > >
\par > > STDMETHODIMP GetInterface
\par > > (
\par > > /*[in]*/ BSTR bstrObj, // Name of the object
\par > > /*[out, retval]*/ VARIANT *pvarObj // Returned object
\par > > )
\par > > \{
\par > > CComPtr<IDispatch> pObj;
\par > > IDispatch* pDispatch = NULL;
\par > > HRESULT hr = pObj.CoCreateInstance( bstrObj );
\par > >
\par > > if( SUCCEEDED( hr ) )
\par > > \{
\par > > if( pObj )
\par > > hr = pObj->QueryInterface( IID_IDispatch,
\par > > (void**)&pDispatch );
\par > > else
\par > > hr = E_NOINTERFACE;
\par > > \}
\par > >
\par > > VariantClear( pvarObj );
\par > > V_VT( pvarObj ) = VT_DISPATCH;
\par > > V_DISPATCH( pvarObj ) = pDispatch;
\par > >
\par > > return hr;
\par > > \}
\par > >
\par > > Finally, you will need to make some changes to your HTML code - something
\par > > like this:
\par > >
\par > > var objXML = new ActiveXObject( "ComAdapter.ComObject" );
\par > > var objRealXML = objXML.GetInterface( "Microsoft.XMLHTTP" );\tab
\par > > objRealXML.open( "POST", url, true );
\par > >
\par > >
\par > > ---
\par > >
\par > > Nathan Lewis
\par > > Microsoft Mobile and Embedded Devices Developer Support
\par > >
\par > > This posting is provided "AS IS" with no warranties, and confers no
\par > rights.
\par > >
\par > >
\par > >
\par > > --------------------
\par > > From: =?Utf-8?B?U2hsb21p?= <Shlomi@discussions.microsoft.com>
\par > > Subject: XMLHTTP doesn't work, I'm getting access denied
\par > > Date: Wed, 16 Feb 2005 05:19:03 -0800
\par > >
\par > >
\par > > Hello,
\par > >
\par > > I need to write a web application for my pocket PC, here is part of the
\par > > code I'm using:
\par > >
\par > > xrequest = new ActiveXObject("Microsoft.XMLHTTP");
\par > > xrequest.open("POST",url,true );
\par > >
\par > > I'm getting access denied when trying to execute the open method.
\par > >
\par > > The same code works fine when running it using scripting host on the same
\par > > pocket PC. Also, the same code works fine on another iPaq I have that
\par > uses
\par > > win CE 4
\par > >
\par > > Trying to change the security setting in the registry didn't help.
\par > >
\par > > Can someone please help
\par > >
\par > > Thanks,
\par > > Shlomi
\par > >
\par > >
\par >
\par \pard
\par
\par }
------=_NextPart_0001_31C96BB2--