473,322 Members | 1,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Calling J2EE web service from .NET

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.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)

at System.Web.Services.Protocols.SoapHttpClientProtoc ol.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?

Thanks in advance.

-Rick

Jun 27 '07 #1
2 2989
"RNoel" <RN***@discussions.microsoft.comwrote in message
news:5D**********************************@microsof t.com...
>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.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)

at System.Web.Services.Protocols.SoapHttpClientProtoc ol.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]
Jun 27 '07 #2
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" <RN***@discussions.microsoft.comwrote in message
news:5D**********************************@microsof t.com...
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.SoapHttpClientProtoc ol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)

at System.Web.Services.Protocols.SoapHttpClientProtoc ol.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]
Jun 28 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Herman | last post by:
Hi everyone, I'm currently studying for my Master's in Computer Science, and I will be working on my thesis this summer. I've been thinking about constructing a web services application for my...
124
by: 43 | last post by:
how come m$Office isn't written in .net? how come Open Office isn't written in j2ee? how come dbms systems aren't written in either? how come browsers aren't written in either? how come...
4
by: leslie_tighe | last post by:
Hello, I have a webservice running on a J2EE server created with Axis 1.2.. I have a client that I am building in .net that needs to consume this webserivce and am having a bit of trouble. I have...
0
by: ben | last post by:
OK so there are a few things going on. I succesfully created a SOAP webreference in VS IDE which when built works fine under small amounts of load, however under heavy amounts of load we start to...
3
dmjpro
by: dmjpro | last post by:
plz send me a good link which can clearify me how the J2EE framework works i want the details information .... plz help thanx
9
dmjpro
by: dmjpro | last post by:
today i came to know a new framework .... say SPRING. can u give me good link on it??? kind regards, dmjpro.
4
by: gengyue | last post by:
Hi, I need to call .Net webservice from my JSP page. My application is Struts application. It is deployed on Oracle application server. Here is the whole process. I have a login form. When user...
4
by: gengyue | last post by:
Hi, I need to call .Net webservice from my JSP page. My application is Struts application. It is deployed on Oracle application server. Here is the whole process. I have a login form. When user...
4
by: Scott M. | last post by:
Believe it or not, I've searched quite a bit and can't find any relevant information on how to consume a J2EE web service from a .NET consumer WITHOUT the aid of any 3rd party tools. I have two...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.