Title: Problem building my handler
Hi
I’m trying to build a handler to run with Axis 1.3. The goal of this handler would be to update the SOAP message to add WS-Security information using the WSS4J library (I know there’s a handler provided with WSS4J, but I simply need to build a simplified version of that).
>From what i understand of handlers, the way I should do that is as shown below. Everything works fine: the document d contains the wsse element as expected. The question is: how do I recreate a soap message from the Document object?
Thanks for your help
Jean-Noel Colin
Message requestMessage = arg0.getCurrentMessage(); SOAPEnvelope env = requestMessage.getSOAPEnvelope(); SOAPConstants soapConstants = env.getSOAPConstants(); Crypto crypto = CryptoFactory.getInstance("client-wss.properties"); Vector parts = new Vector(); WSEncryptionPart part = new WSEncryptionPart(soapConstants.getBodyQName().getLocalPart(), soapConstants.getEnvelopeURI(), "Content"); parts.add(part); WSSignEnvelope signer = new WSSignEnvelope(); signer.setUserInfo("client", "client-ks"); signer.setParts(parts); // this is optional since the body is signed by default Document d=null; try { Document origDoc = env.getAsDocument(); d = signer.build(origDoc, crypto); } catch (WSSecurityException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); }
