473,756 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Netw orkCredential(" username", "password")

ws.Credentials = cred

Dim resp As WSRef.myMethodR esponse = myWS.myOper(ope r)

When the code runs it gets back the following error:

ERROR:

System.Net.WebE xception: The request failed with HTTP status 401:
Unauthorized.

at
System.Web.Serv ices.Protocols. SoapHttpClientP rotocol.ReadRes ponse(SoapClien tMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)

at System.Web.Serv ices.Protocols. SoapHttpClientP rotocol.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 3002
"RNoel" <RN***@discussi ons.microsoft.c omwrote in message
news:5D******** *************** ***********@mic rosoft.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.Netw orkCredential(" username", "password")

ws.Credentials = cred

Dim resp As WSRef.myMethodR esponse = myWS.myOper(ope r)

When the code runs it gets back the following error:

ERROR:

System.Net.WebE xception: The request failed with HTTP status 401:
Unauthorized.

at
System.Web.Serv ices.Protocols. SoapHttpClientP rotocol.ReadRes ponse(SoapClien tMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)

at System.Web.Serv ices.Protocols. SoapHttpClientP rotocol.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.Netw orkCredential(" username", "password")
Dim u As New Uri(ws.Url)
Dim icred As System.Net.ICre dentials = cred.GetCredent ial(u, "Basic")

ws.Credentials = icred

Dim resp As WSRef.myMethodR esponse = myWS.myOper(ope r)

-Rick

"John Saunders [MVP]" wrote:
"RNoel" <RN***@discussi ons.microsoft.c omwrote in message
news:5D******** *************** ***********@mic rosoft.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.Netw orkCredential(" username", "password")

ws.Credentials = cred

Dim resp As WSRef.myMethodR esponse = myWS.myOper(ope r)

When the code runs it gets back the following error:

ERROR:

System.Net.WebE xception: The request failed with HTTP status 401:
Unauthorized.

at
System.Web.Serv ices.Protocols. SoapHttpClientP rotocol.ReadRes ponse(SoapClien tMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)

at System.Web.Serv ices.Protocols. SoapHttpClientP rotocol.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
7696
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 thesis, as I've been interested in this technology, and I haven't had a chance to work with it in my last job. The issue is what platform to use: ..NET or J2EE? Prior to starting my MSc course, I worked for a software developer for five years...
124
4954
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 RealPlayer, MediaPlayer and all applications that need speed are written in c++ ? (except for
4
1977
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 pasted the wsdl below and have a created a class in VB.net by adding a web refrence to my project. What is odd is that I can successfully call methods that return a simple value like a string. I call also call methods that add an object....
0
1372
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 see a performance issue on the J2EE (CPU utilisation max's out) the load testing tool can hit the web service directly using HTTP posts and for the same amount of load the webservice performs considerably better. So the JAVA guys have asked me if...
3
6624
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
2821
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
3872
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 hit login button, my Action class will validate the user information and send his information to the other site by calling .Net web service, so the other site can extract these information. So, in my jsp, I am using Javascript and webservice.htc to...
4
4121
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 hit login button, my Action class will validate the user information and send his information to the other site by calling .Net web service, so the other site can extract these information. So, in my jsp, I am using Javascript and webservice.htc to...
4
1649
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 questions: 1. In a nutshell, how is this accomplished? 2. Are there any publicly available J2EE web services out there that I can try this against? I don't have the ability to create the J2EE side of the
0
9462
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9287
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10046
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9886
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9857
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9722
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8723
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2677
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.