You're welcome Davie,
Have a good day!
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Davie" <
[email protected]>
| References: <
[email protected]>
<
[email protected]>
<#
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
| Subject: Re: AuthHeaderValue with Webservice
| Date: Sun, 2 Oct 2005 00:04:15 +0100
| Lines: 305
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| Message-ID: <#
[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: client-82-13-28-213.brhm.adsl.virgin.net 82.13.28.213
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.languages.csharp:126028
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Many thanks Steven.
|
| Your help is much appreciated.
|
| Regards,
| Davie.
|
|
| | > Hi Davie,
| >
| > Well, I've managed to got a physical machine for testing with asp.net2.0
| > webservice and vs.net2003 smartphone 2003 project, and did find the
| > problem
| > you mentioned. After some further investigate, I found that the
| > NullReference exception is just thrown at clientside (no SOAP message is
| > sent out event). So I check the generated proxy's source file and
compiled
| > the one with that I generated from a ASP.NET 1.X webservice and got the
| > cause:
| >
| > when comsuming the ASP.NET 2.0 webservice, the clientproxy will generate
| > the following class for soapheader(AuthHeader)
| >
| >
| >
| >
[System.Xml.Serialization.XmlTypeAttribute(Namespace="
http://tempuri.org/")]
| >
| >
[System.Xml.Serialization.XmlRootAttribute(Namespace="
http://tempuri.org/",
| > IsNullable=false)]
| > public class AuthHeader : System.Web.Services.Protocols.SoapHeader {
| >
| > /// <remarks/>
| > public string Username;
| >
| > /// <remarks/>
| > public string Password;
| >
| > /// <remarks/>
| > [System.Xml.Serialization.XmlAnyAttributeAttribute()]
| > public System.Xml.XmlAttribute[] AnyAttr;
| > }
| >
| >
| > Note that the
| > /// <remarks/>
| > [System.Xml.Serialization.XmlAnyAttributeAttribute()]
| > public System.Xml.XmlAttribute[] AnyAttr;
| >
| > is the one which cause the problem, this field won't be generated for
| > asp.net 1.1 webservice. After comment this field, I can make the
webmethod
| > call correctly. Also, seems this doesn't matter for normal desktop or
| > console application, maybe something incorrect with the webservice
| > implementaiton on smartphone 2003 platform's compact framework.
| >
| > Anyway, I think you can manually commet/remove that "AnyAttr" field in
| > your
| > proxy soapheader class to see whether it works.
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure!
www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| >
| >
| >
| > --------------------
| > | From: "Davie" <
[email protected]>
| > | References: <
[email protected]>
| > <
[email protected]>
| > <#
[email protected]>
| > <
[email protected]>
| > | Subject: Re: AuthHeaderValue with Webservice
| > | Date: Thu, 29 Sep 2005 13:26:18 +0100
| > | Lines: 187
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| > | X-RFC2646: Format=Flowed; Original
| > | Message-ID: <
[email protected]>
| > | Newsgroups: microsoft.public.dotnet.languages.csharp
| > | NNTP-Posting-Host: client-82-12-235-246.brnt.adsl.virgin.net
| > 82.12.235.246
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl
| > microsoft.public.dotnet.languages.csharp:125568
| > | X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
| > |
| > | I haven't tried this in a .NET 1.1. environment, since I need my web
| > | services to run in .NET 2.0. I am aware that the release date for
.NET
| > 2.0
| > | is sometime in November.
| > |
| > | I do know that the .NET 2.0 webservice works with .NET 1.1 Windows app
| > | clients but not .NET CF 1.1. clients.
| > |
| > | What do you suggest?
| > |
| > | Thanks.
| > | Davie.
| > |
| > |
| > |
| > | | > | > Hi Davie,
| > | >
| > | > Thanks for your further response and the test application you
| > provided.
| > | > It
| > | > seems that your webservice is created in asp.net 2.0 project. Due to
| > | > environment limitation, I just have tested in a VS.NET 2003/ .NET
| > | > FRAMEWORK
| > | > 1.1 environment (smartphone 2003 emulator...) and found that the
| > | > clientside
| > | > can correctly use the SoapHeader to send info to service. So have
you
| > also
| > | > tried this in a vs.net 2003 /.net 1.1 environment?
| > | >
| > | > Thanks,
| > | >
| > | > Steven Cheng
| > | > Microsoft Online Support
| > | >
| > | > Get Secure!
www.microsoft.com/security
| > | > (This posting is provided "AS IS", with no warranties, and confers
no
| > | > rights.)
| > | >
| > | >
| > | >
| > | > --------------------
| > | > | From: "Davie" <
[email protected]>
| > | > | References: <
[email protected]>
| > | > <
[email protected]>
| > | > | Subject: Re: AuthHeaderValue with Webservice
| > | > | Date: Wed, 28 Sep 2005 11:22:27 +0100
| > | > | Lines: 854
| > | > | X-Priority: 3
| > | > | X-MSMail-Priority: Normal
| > | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| > | > | X-RFC2646: Format=Flowed; Original
| > | > | Message-ID: <#
[email protected]>
| > | > | Newsgroups: microsoft.public.dotnet.languages.csharp
| > | > | NNTP-Posting-Host: client-82-2-87-237.manc.adsl.virgin.net
| > 82.2.87.237
| > | > | Path:
| > TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| > | > | Xref: TK2MSFTNGXA01.phx.gbl
| > | > microsoft.public.dotnet.languages.csharp:125274
| > | > | X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
| > | > |
| > | > | Thanks Steven.
| > | > |
| > | > | Apologies for the multiple posting, I thought that my news client
| > was
| > | > | playing up and sent multiple copies.
| > | > |
| > | > | I have included my two project files. One is the client and the
| > other
| > | > is
| > | > | the web service. The Client is built for smartphone, but I have
| > tried
| > | > it
| > | > | out on Pocket PC as well. Both do not work!
| > | > |
| > | > | If try to pass the custom soap headers from a desktop version, it
| > seems
| > | > to
| > | > | work fine. I've looked at the generated proxy classes and I
can't
| > see
| > | > any
| > | > | difference between the .NET and the .NET CF ones.
| > | > |
| > | > | I would greatly appreciate any assistance.
| > | > |
| > | > | Kind Regards,
| > | > | Davie.
| > | > |
| > | > |
message
| > | > | | > | > | > Hi Davie,
| > | > | >
| > | > | > Welcome to MSDN newsgroup.
| > | > | > From your description, you're using the .NET framework to build
a
| > | > | > webservice and conumse it in client app through .NET webservice
| > proxy.
| > | > You
| > | > | > also add a custom propety for the webservice so as to pass
| > | > athorization
| > | > | > info. You find that this works well when in normal .net app, but
| > | > always
| > | > | > get
| > | > | > Null reference exception when used in compact framework, yes?
| > | > | >
| > | > | > As for the AuthHeader (from the code you provided), is it a
custom
| > | > | > SoapHeader you defined in your webservice? If so, would you
| > provide
| > | > the
| > | > | > detailed code of your webservice definition. Also, have you
| > compared
| > | > the
| > | > | > clientside proxy classes generated in the normal .net client and
| > | > compact
| > | > | > framework client to see whether there're any difference on the
| > | > soapheader
| > | > | > declaration?
| > | > | >
| > | > | > If there're any other finding, please feel free to post here.
| > | > | >
| > | > | > Thanks,
| > | > | >
| > | > | > Steven Cheng
| > | > | > Microsoft Online Support
| > | > | >
| > | > | > Get Secure!
www.microsoft.com/security
| > | > | > (This posting is provided "AS IS", with no warranties, and
confers
| > no
| > | > | > rights.)
| > | > | >
| > | > | >
| > | > | >
| > | > | >
| > | > | >
| > | > | >
| > | > | >
| > | > | > --------------------
| > | > | > | From: "Davie" <
[email protected]>
| > | > | > | Subject: AuthHeaderValue with Webservice
| > | > | > | Date: Mon, 26 Sep 2005 17:18:26 +0100
| > | > | > | Lines: 26
| > | > | > | X-Priority: 3
| > | > | > | X-MSMail-Priority: Normal
| > | > | > | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| > | > | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| > | > | > | X-RFC2646: Format=Flowed; Original
| > | > | > | Message-ID: <
[email protected]>
| > | > | > | Newsgroups: microsoft.public.dotnet.languages.csharp
| > | > | > | NNTP-Posting-Host: client-82-13-29-18.brhm.adsl.virgin.net
| > | > 82.13.29.18
| > | > | > | Path:
| > | > TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
| > | > | > | Xref: TK2MSFTNGXA01.phx.gbl
| > | > | > microsoft.public.dotnet.languages.csharp:124808
| > | > | > | X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
| > | > | > |
| > | > | > | I want to authorise a user of a web service by using the
| > | > AuthHeaderValue
| > | > | > for
| > | > | > | some reason I keep getting a null reference exception when I
try
| > to
| > | > run
| > | > | > the
| > | > | > | following code: It seems to work fine on a .NET Framework
| > | > application,
| > | > | > but
| > | > | > | just not on the .NET CF version.
| > | > | > |
| > | > | > | Can anyone suggest anything that might be wrong with the
code?
| > (I
| > | > could
| > | > | > | post the app and webservice, but i was hoping that you might
| > have
| > | > | > noticed
| > | > | > | something from the supplied code).
| > | > | > |
| > | > | > | Many thanks.
| > | > | > |
| > | > | > |
| > | > | > |
| > | > | > | WebServices service = new WebServices();
| > | > | > |
| > | > | > | Webservices.AuthHeader Credentials = new
| > Webservices.AuthHeader();
| > | > | > |
| > | > | > | Credentials.UserName = "user";
| > | > | > |
| > | > | > | Credentials.Password = "P@ssword";
| > | > | > |
| > | > | > | service.AuthHeaderValue = Credentials;
| > | > | > |
| > | > | > | loggedin = service.login();
| > | > | > |
| > | > | > |
| > | > | > |
| > | > | >
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|