Web Service acces with authentication

A

Alexandru Florea

Hello,

I tried to acces a web service from a C# application running on a pocketPC.
It only works if I enable anonymous acces in IIS authentication properties.
Otherwise I got the following error :

"Server found request content type to be 'text/html', but expected
'text/xml'."

The code I used look like this:

phws3001 phws3001WebService = new phws3001();

phws3001WebService.Url = GlobalVarsClass.sWebServiceURL;

phws3001WebService.PreAuthenticate = true;

// Set the client-side credentials using the Credentials property.

NetworkCredential myCred = new NetworkCredential(GlobalVarsClass.sLoginName,
GlobalVarsClass.sLoginPass);

phws3001WebService.Credentials = myCred;

string sData = phws3001WebService.SyncronizeData();


In a PC desktop applocation I should use the CredentialCache class in order
to work properly, but .NET Compact Framework doesn't support this class.

An embeddedVB 3.0 application using the same WebService and running on the
same pocket works ok, so it should work in C# either, I supose.

Any ideea ?

Thank you,
Alex
 
M

Mike Boilen [MS]

That means that the response to the web service call was actually an html
page, rather than a soap response. Unfortunately, there is no good way to
obtain the actual html page returned by the web server.

Mike Boilen
Developer
.NET Compact Framework

This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.gotdotnet.com/team/netcf/FAQ.aspx

--------------------
| From: (e-mail address removed) (Victor Romanchuk)
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Subject: Re: Web Service acces with authentication
| Date: 26 Aug 2003 10:54:46 -0700
| Organization: http://groups.google.com/
| Lines: 9
| Message-ID: <[email protected]>
| References: <#[email protected]>
| NNTP-Posting-Host: 80.255.79.230
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google.com 1061920487 5243 127.0.0.1 (26 Aug 2003
17:54:47 GMT)
| X-Complaints-To: (e-mail address removed)
| NNTP-Posting-Date: 26 Aug 2003 17:54:47 GMT
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onlin
e.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-06!sn-
xit-09!supernews.com!postnews1.google.com!not-for-mail
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:32057
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| I have same error when connected to JAVA Tomcat/JBoss Web Service:
|
| "--->>>
| Exception type : System.InvalidOperationException
| Module : PocketClient.Service
| Method : getUser()
| Exception message : Server found request content type to be
| 'text/html; charset=iso-8859-1', but expected 'text/xml'.
| <<<---"
|
 
V

Victor Romanchuk

That means that the response to the web service call was actually an html
page, rather than a soap response. Unfortunately, there is no good way to
obtain the actual html page returned by the web server.

Mike Boilen
Developer
.NET Compact Framework

Mike, you are right . :)
My exception is result my experiments with other ways for make auth
access to non Windows web services.

Victor Romanchuk
Ukraine
 
M

Mike Boilen [MS]

You're best bet here is to enable Basic or Digest authentication. When you
use Basic authentication, your password is transfered in the clear, whereas
for Digest authentication, your password is hashed, and is relatively
secure (against theft, replay, etc). IIS allows you to specify a specific
password when you use Basic authentication, and for Digest, you use domain
passwords.

In both cases, you can attach a NetworkCredential instance to the instance
of the web service proxy class (through the Credentials property). This
will cause the .net CF to authenticate the client to the web service.


Mike Boilen
Developer
.NET Compact Framework

This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.gotdotnet.com/team/netcf/FAQ.aspx

--------------------
| From: (e-mail address removed) (Victor Romanchuk)
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Subject: Re: Web Service acces with authentication
| Date: 28 Aug 2003 12:42:00 -0700
| Organization: http://groups.google.com/
| Lines: 14
| Message-ID: <[email protected]>
| References: <#[email protected]>
<[email protected]>
<[email protected]>
| NNTP-Posting-Host: 80.255.79.252
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google.com 1062099720 1011 127.0.0.1 (28 Aug 2003
19:42:00 GMT)
| X-Complaints-To: (e-mail address removed)
| NNTP-Posting-Date: 28 Aug 2003 19:42:00 GMT
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onlin
e.de!newsfeed.freenet.de!194.168.4.91.MISMATCH!newspeer1-gui.server.ntli.net
!ntli.net!in.100proofnews.com!in.100proofnews.com!cyclone.bc.net!sjc70.webus
enet.com!news.webusenet.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!post
news1.google.com!not-for-mail
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:32275
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| > That means that the response to the web service call was actually an
html
| > page, rather than a soap response. Unfortunately, there is no good way
to
| > obtain the actual html page returned by the web server.
| >
| > Mike Boilen
| > Developer
| > .NET Compact Framework
|
| Mike, you are right . :)
| My exception is result my experiments with other ways for make auth
| access to non Windows web services.
|
| Victor Romanchuk
| Ukraine
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top