I've a problem with signing SOAP messages with certificate. There is also on top of that HTTP Base Authentication, bu I've only a problem with certs. Let's say I've a single file
cert.pxf
and pasword to this file
passPhrase123
I have code like this:
public class ClientTest {
public static void main(String[] args) {
SomeService ss = new SomeService();
SSPortType ssPortType = ss.getSSPortType();
BindingProvider provider = (BindingProvider) ssPortType;
provider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://193.105.143.152:8001/ws/zus.channel.gabinetoweV2:zla");
provider.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "ezla_ag");
provider.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "ezla_ag");
Binding binding = provider.getBinding();
List<Handler> handlerList = binding.getHandlerChain();
handlerList.add(new CertHandler());
binding.setHandlerChain(handlerList);
String str = ssPortType.rpcCall();
System.out.println(str);
}
}
And LogicalHandler for dealing with signing SOAP message:
public class CertHandler implements LogicalHandler<LogicalMessageContext> {
public Set<QName> getHeaders() {
return Collections.EMPTY_SET;
}
public boolean handleMessage(LogicalMessageContext context) {
Boolean isOutbound = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (isOutbound.booleanValue()) {
System.out.println("I've got an outbound message");
LogicalMessage msg = context.getMessage();
Source src = msg.getPayload();
try {
Node root = null;
Document doc = null;
System.out.println("Try to get body");
if (src instanceof DOMSource) {
System.out.println("Hello DOM src");
root = ((DOMSource)src).getNode();
}
else if (src instanceof SAXSource) {
System.out.println("Hello SAX src");
SAXSource saxSource = (SAXSource) src;
InputSource inSource = saxSource.getInputSource();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
doc = db.parse(inSource);
root = (Node) doc.getDocumentElement();
}
//Deal with signing a root
}
catch (SAXException se) {
System.out.println("se: " + se.getMessage());
}
catch (ParserConfigurationException pce) {
System.out.println("pce: " + pce.getMessage());
}
catch (IOException ioe) {
System.out.println("ioe: " + ioe.getMessage());
}
catch (IllegalArgumentException iae) {
System.out.println("iae: " + iae.getMessage());
System.out.println(iae.getLocalizedMessage());
}
}
else {
System.out.println("I've got an incoming message");
}
return false;
}
public boolean handleFault(LogicalMessageContext context) {
return true;
}
public void close(MessageContext context) {
}
}
Unfortunately I receive always and always again:
I've got an outbound message
Try to get body
Hello SAX src
ioe: null
I got totally stuck... Please help. :)
Could you paste me a small code snippet with solution or point me where I'll get help? Thanks in advance!