File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JNLP and Web Start and the fly likes Web Start client for two Web Services Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JNLP and Web Start
Bookmark "Web Start client for two Web Services" Watch "Web Start client for two Web Services" New topic

Web Start client for two Web Services

Dmitriy Fot

Joined: Sep 13, 2005
Posts: 2

I wrote a client application that uses two different web services.
Both web services are created using Basic Authentication. They have different user_names and passwords, but must be deployed on the same application server. I must invoked methods of these web services one after another.The problem occures when I invokes mehods of second web service. No matter which of service would be first or second. The problem occurs on second calling. I got this exception:

EXCEPTION: java.rmi.RemoteException: HTTP Status-Code 403: Access to the requested resource has been denied; nested exception is:
HTTP Status-Code 403: Access to the requested resource has been denied
at com.softlets.insurelet.test.TestRefundPolicy.main(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

IMPORTANT: Everything worked fine until I started to install this application using Java Web Start.

MY ASSUMPTION: It's likely to me that web start executes my application in some environment where it caches the first web service's username and password and applies it to the second web service. Because, if I run both web services on my local machine and set ENDPOINT_ADDRESS_PROPERTY to different values (first - localhost:8080, second - everything works fine.

public static void main(String[] args) {
try {
String user = "test"; String pass ="test";
String host = "";

Stub stub = (Stub)(new Insurelet_policies_Impl().getInsureletPoliciesServiceSEIPort()); stub1._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY, host);
stub._setProperty(javax.xml.rpc.Stub.USERNAME_PROPERTY, user);
stub._setProperty(javax.xml.rpc.Stub.PASSWORD_PROPERTY, pass);

InsureletPoliciesServiceSEI ws = (InsureletPoliciesServiceSEI)stub;

String officeid = "test1"; String operatorid = "test2"; String mct = "1";
boolean result = ws.makeRefund(officeid, operatorid, mct);

String suser = "test"; String spass ="test";
String shost = "";

Stub stub1 = (Stub)(new Insurelet_security_Impl()).getInsureletSecurityServiceSEIPort();
stub1._setProperty(javax.xml.rpc.Stub.USERNAME_PROPERTY, suser);
stub1._setProperty(javax.xml.rpc.Stub.PASSWORD_PROPERTY, spass);
stub1._setProperty(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY, shost);

InsureletSecurityServiceSEI ws1 = (InsureletSecurityServiceSEI)stub1;

OperatorTO to = ws1.login("softlets", "admin", "admin"); // EXCEPTION

ENVIRONMENT: Both web services are deployed in a single enterprise application on Sun Java System Application Server 8.1.
Java version: 1.5..0_02
I agree. Here's the link:
subject: Web Start client for two Web Services
It's not a secret anymore!