WSE Headers across multiple operations - Weblogic

This is a discussion on WSE Headers across multiple operations - Weblogic ; Hi, I have a WebLogic client that is talking to a remote server from another vendor. The server requires WSE 1.0 Credentials to be sent across the wire. I have this working, however, the credentials are not being sent on ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: WSE Headers across multiple operations

  1. WSE Headers across multiple operations

    Hi,

    I have a WebLogic client that is talking to a remote server from another vendor. The server requires WSE 1.0 Credentials to be sent across the wire. I have this working, however, the credentials are not being sent on my second operation. The server requires that the headers are sent on all operations. Is there someway to do this?

    My code so far looks like:



    //Add WSE credential information to request
    SecurityElementFactory factory = SecurityElementFactory.getDefaultFactory();
    Token userToken = factory.createToken(user_credentials[0], user_credentials[1]);
    Security security = factory.createSecurity(null);

    // add the username/password to the header as a UsernameToken
    security.addToken(userToken);

    //Add the security element to the request...
    WebServiceContext context = service_proxy.context();
    WebServiceSession session = context.getSession();
    session.setAttribute(WSSEClientHandler.REQUEST_SEC URITY, security);


    I've also used played around with these guys too:

    UserInfo ui = new UserInfo(AUTHENTICATION_USER, AUTHENTICATION_USER_PASS);
    session.setAttribute(WSSEClientHandler.REQUEST_USE RINFO, ui);

    I'm using WebLogic SP3 on windows and I'm not use the Workshop. Just java and clientgen.

    Thank you.

  2. Re: WSE Headers across multiple operations

    Hi, I am also facing the same issue like Action, ReplyTO, TO, Missing ID and Security is missing in header. I am using plain java and client gen. Could you able to solve this problem? i am struct and could not go further.

    Your help is needed.

    My code is pasted below:

    try {
    //Calendar cal = Calendar.getInstance();
    EMAP_PreferenceWS_Sec_Impl emp = new EMAP_PreferenceWS_Sec_Impl(url);
    WebServiceContext context = emp.context();
    WebServiceSession session = context.getSession () ;

    QName portName = new QName("http://gmacws.merkleinc.com/wsdl", "EMAP_PreferenceWS_SecSoap");



    //Added by Srinivas for security Reasons
    HandlerRegistry registry = emp.getHandlerRegistry();

    HandlerInfo hi = new HandlerInfo();
    hi.setHandlerClass(com.gmac.privacypreference.webs ervices.handler.PrivacyClientHandler.class);

    List list = registry.getHandlerChain(portName);
    list.add(hi);
    registry.setHandlerChain(portName, list);




    // load the client credential
    X509Certificate clientcert = getCertificate(KEY_ALIAS, CLIENT_KEYSTORE,KEY_PASSWORD);

    PrivateKey clientprivate = (PrivateKey) getPrivateKey(KEY_ALIAS, KEY_PASSWORD, CLIENT_KEYSTORE,KEY_PASSWORD);



    // load the server's certificate...
    X509Certificate serverCert = getCertificate(SERVER_KEY_ALIAS, SERVER_KEYSTORE,SERVER_KEY_ALIAS);


    // configure the Security element for the service.
    SecurityElementFactory factory = SecurityElementFactory.getDefaultFactory();
    Token x509Token = factory.createToken(clientcert, clientprivate);
    Token userToken = factory.createToken(USERNAME, USER_PASSWORD);

    //Token userToken = factory.createToken(USERNAME, USER_PASSWORD);
    SignatureSpec signatureSpec = SignatureSpec.getDefaultSpec();
    EncryptionSpec encSpec = EncryptionSpec.getDefaultSpec();

    Token serverToken = null;

    serverToken = factory.createToken(serverCert, null);


    Security security = factory.createSecurity(null);
    security.addToken(userToken);

    security.addSignature(x509Token, signatureSpec);

    security.addToken(x509Token);

    security.addEncryption(serverToken, encSpec);



    //UserInfo ui = new UserInfo ( userName, password) ;

    //session.setAttribute ( WSSEClientHandler.REQUEST_USERINFO, ui ) ;


    // add the security element to the request...

    //session.setAttribute("weblogic.webservice.security.request",security);
    session.setAttribute(WSSEClientHandler.REQUEST_SEC URITY, security);



    // Client call
    EMAP_PreferenceWS_SecSoap empSoap = emp.geteMAP_PreferenceWS_SecSoap12();//emp.geteMAP_PreferenceWS_SecSoap12();



    GMACWSHeader gws = new GMACWSHeader(userName,password);




    System.out.println(" Response of Soap Message "+ empSoap.validateCustomer("5","ANNA","SIMONS", gws));
    //empSoap.



    //empSoap.validateCustomer("5","ANNA","SIMONS",gws);
    //System.out.println(" Completed Calling Validate Consumer ID " +result);
    System.out.println("Execution DONE....");
    // view the assertions from processing the server's response...
    /*SecurityAssertion[] assertions = (SecurityAssertion[])context.getSession().getAttribute("weblogic.webservice.security.assertions.response");
    for (int i = 0; i < assertions.length; i++) {
    SecurityAssertion assertion = assertions[i];
    System.out.println(" Assertion is : "+ assertion);
    }*/




    }catch(Exception ex) {
    ex.printStackTrace();
    }





    Quote Originally Posted by Susan Javurek View Post
    Hi,

    I have a WebLogic client that is talking to a remote server from another vendor. The server requires WSE 1.0 Credentials to be sent across the wire. I have this working, however, the credentials are not being sent on my second operation. The server requires that the headers are sent on all operations. Is there someway to do this?

    My code so far looks like:



    //Add WSE credential information to request
    SecurityElementFactory factory = SecurityElementFactory.getDefaultFactory();
    Token userToken = factory.createToken(user_credentials[0], user_credentials[1]);
    Security security = factory.createSecurity(null);

    // add the username/password to the header as a UsernameToken
    security.addToken(userToken);

    //Add the security element to the request...
    WebServiceContext context = service_proxy.context();
    WebServiceSession session = context.getSession();
    session.setAttribute(WSSEClientHandler.REQUEST_SEC URITY, security);


    I've also used played around with these guys too:

    UserInfo ui = new UserInfo(AUTHENTICATION_USER, AUTHENTICATION_USER_PASS);
    session.setAttribute(WSSEClientHandler.REQUEST_USE RINFO, ui);

    I'm using WebLogic SP3 on windows and I'm not use the Workshop. Just java and clientgen.

    Thank you.

+ Reply to Thread