问题描述
我在使用证书签署SOAP消息时遇到问题。 在HTTP Base Authentication之上,还有cert的问题。 假设我只有一个文件
cert.pxf
passphrase123
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);
}
}
用于处理签名SOAP消息的LogicalHandler:
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) {
}
}
不幸的是,我总是收到一遍又一遍:
I've got an outbound message
Try to get body
Hello SAX src
ioe: null
我完全被困住了... 请帮忙。 :)
您能给我粘贴一个带有解决方案的小代码段,还是向我指出可以帮助的地方? 预先感谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)