Re: Calling J2EE web service from .NET



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]



.



Relevant Pages

  • Re: Template Emulation?
    ... some way to emulate C++ templates in order to tell the Java compiler to ... public Vec(int dim) { ... Is there any way to achieve this in Java? ... What if I declared dim as static final in the class Vec? ...
    (comp.lang.java.programmer)
  • OWA Calendarview script error.
    ... There is a system of Java functions that is responsible ... XML returned by the xmlhttp.responseXML.xml object because ... Dim xmlDoc As New MSXML2.DOMDocument30 ... >the calendar folder, ...
    (microsoft.public.exchange.connectivity)
  • Re: HELP PLEASE The request failed with HTTP status 401: Access Denied.
    ... Try changing to Integrated Windows Authentication on IIS instead of basic or ... > We have basic authentication on through IIS. ... > Dim credentials As System.Net.NetworkCredential = New ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Rollover button problem
    ... | I'm building a site in Dreamweaver MX where I have a set of rollover ... These buttons go dim when the mouse is over them. ... | understanding Java script code so let me know what bits might help ... You have posted to a java newsgroup. ...
    (comp.lang.java.softwaretools)
  • Re: FileExists problems
    ... if you change the http header to the physical drive, ... > from my understanding and examples on the web an in this forum the ... > Dim file As String ... > Dim vTryDocuments() As Variant ...
    (microsoft.public.visio.developer.vba)