Re: Calling J2EE web service from .NET
- From: RNoel <RNoel@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 28 Jun 2007 10:20:02 -0700
When I run my Java test, according to netmon, the HTTP header of the request
contains a "Basic Authentication" section with the realm containing a UserId
and PassWord. When I make the call from VB in .NET, however, the HTTP header
does not contain the "Basic Authentication" at all. How do I get it to
include it? I've tried the following code as well, but to no avail.
Dim ws As New WSRef.X_WS
Dim oper As New WSRef.myOper
Dim cred As New System.Net.NetworkCredential("username", "password")
Dim u As New Uri(ws.Url)
Dim icred As System.Net.ICredentials = cred.GetCredential(u, "Basic")
ws.Credentials = icred
Dim resp As WSRef.myMethodResponse = myWS.myOper(oper)
-Rick
"John Saunders [MVP]" wrote:
"RNoel" <RNoel@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message.
news:5D855CDD-27DC-4195-93A9-B245C47885E5@xxxxxxxxxxxxxxxx
I implemented a J2EE web service on Sun's Application Server 8. The web
service is set up to require BASIC authentication. I created a Java
client
that passes credenttials for the authentication and all went well.
I then tried to add a web reference to a client project in .NET using VB.
My code is essentially (WSRef is the name of my added web service
reference):
Dim ws As New WSRef.X_WS
Dim oper As New WSRef.myOper
Dim cred As New System.Net.NetworkCredential("username", "password")
ws.Credentials = cred
Dim resp As WSRef.myMethodResponse = myWS.myOper(oper)
When the code runs it gets back the following error:
ERROR:
System.Net.WebException: The request failed with HTTP status 401:
Unauthorized.
at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
...
The given user name and password should work and do using a Java client.
Any idea what might be causing this?
I'd recommend you use a network analyzer such as Microsoft Netmon (see their
blog at http://blogs.technet.com/netmon/). Look at the wire and see how it
looks when it fails and when it succeeds and see what's different.
--
John Saunders [MVP]
- References:
- Re: Calling J2EE web service from .NET
- From: John Saunders [MVP]
- Re: Calling J2EE web service from .NET
- Prev by Date: RE: WSHttpBinding in WCF
- Next by Date: Webservice WCF call from .NET 2.0
- Previous by thread: Re: Calling J2EE web service from .NET
- Next by thread: RE: WSHttpBinding in WCF
- Index(es):
Relevant Pages
|