简体   繁体   中英

Basic Authentication Java SOAP WebService Client

java artifacts for Soap Web Service Client using wsimport from a WSDL. Which produced:

AppPortalSMupdate.java with some sample code from it public interface AppPortalSMupdate {

@WebMethod(operationName = "RetrieveAppPortalSMupdate", action = "Retrieve")
@WebResult(name = "RetrieveAppPortalSMupdateResponse", targetNamespace = "http://schemas.hp.com/SM/7", partName = "RetrieveAppPortalSMupdateResponse")
public RetrieveAppPortalSMupdateResponse retrieveAppPortalSMupdate(
    @WebParam(name = "RetrieveAppPortalSMupdateRequest", targetNamespace = "http://schemas.hp.com/SM/7", partName = "RetrieveAppPortalSMupdateRequest")
    RetrieveAppPortalSMupdateRequest retrieveAppPortalSMupdateRequest);

AppPortalSMupdate_Service.java

@WebServiceClient(name = "AppPortalSMupdate", targetNamespace = "http://schemas.hp.com/SM/7", wsdlLocation ="http://ss_user:sqzblsft@msmapptst001.lvh.com:13088/SM/7/AppPortalSMupdate.wsdl")

public class AppPortalSMupdate_Service extends Service{

private final static URL APPPORTALSMUPDATE_WSDL_LOCATION;
private final static WebServiceException APPPORTALSMUPDATE_EXCEPTION;
private final static QName APPPORTALSMUPDATE_QNAME = new QName("http://schemas.hp.com/SM/7", "AppPortalSMupdate");

static {
    URL url = null;
    WebServiceException e = null;
    try {
        url = new URL("http://ss_user:sqzblsft@msmapptst001.lvh.com:13088/SM/7/AppPortalSMupdate.wsdl");
    } catch (MalformedURLException ex) {
        e = new WebServiceException(ex);
    }
    APPPORTALSMUPDATE_WSDL_LOCATION = url;
    APPPORTALSMUPDATE_EXCEPTION = e;

This is the call to in my main from test client class:

AppPortalSMupdate appUpdate = calc.getAppPortalSMupdate();

UpdateAppPortalSMupdateResponse appResponse = appUpdate.updateAppPortalSMupdate(requestMessage);

My question is the web service needs a user id and password. How do I add a user id and password in my call in the main. This is being used inside a liferay portlet.

use @HandlerChain annotation and configure them by implementing the SOAPHandler interface. Let me know if you need more clarification.

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