简体   繁体   中英

Call web service with forms login on websphere

I have deployed a web service using the @webservice annotation on Websphere 9. To access the web service clients must use a username and password since its hidden behind forms login. This is set up thru the web.xml file. Websphere uses an external LDAP to store the users and passwords. This works when accessing servlets and jsp.

I haven't been able to call my web service thru SoapUI or directly from java client code since all I get back is the login page (which I guess is due to a redirect).

In SoapUI I have selected basic authentication and in java code I have tried both with this ( https://stackoverflow.com/a/496707/1329339 ) and http://user:password@url without success.

This code should be called from a third party once its deployed to production.

EDIT: How do I call the webservice I have created and deployed on websphere 1) from java code and 2) from SoapUI?

EDIT2:

Code:

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService
public class MyWebService {

    @WebMethod
    public String sayHello(String name) {
        return "Hello , " + name;
    }
}

Your client need include user name and password as Authorization HTTP header. You also need change auth-method in web service's web.xml file to "BASIC" from "FORM".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM