也许我可以在这里找到一些帮助。 我需要访问Web服务,但首先我需要使用密钥库验证我的客户端。我不能用春天。 在spring-ws.xml中,这样的配置适用于我的同事的客户:
<bean class="org.springframework.ws.soap.security.wss4j.support.CryptoFactoryBean" id="clientCrypto">
<property name="configuration">
<util:properties>
<prop key="org.apache.ws.security.crypto.provider">org.apache.ws.security.components.crypto.Merlin</prop>
<prop key="org.apache.ws.security.crypto.merlin.keystore.type">jks</prop>
<prop key="org.apache.ws.security.crypto.merlin.keystore.password">${esb.keystore.password}</prop>
<prop key="org.apache.ws.security.crypto.merlin.keystore.alias">${esb.keystore.user}</prop>
<prop key="org.apache.ws.security.crypto.merlin.file">src\main\resources\${esb.keystore.location}</prop>
</util:properties>
</property>
</bean>
我的客户是这样的:
PortalCustomerService service = new PortalCustomerService();
PortalCustomerPortType port = service.getSomethingHttpPort();
BindingProvider bindingProvider = (BindingProvider) port;
Binding binding = bindingProvider.getBinding();
List<Handler> handlerList = binding.getHandlerChain();
handlerList.add(new MyHandler());
binding.setHandlerChain(handlerList);
//calling webmethod
MyResponse response = port.checkClients(getRequest());
和MyHandler有一个方法handleMessage,如下所示:
public boolean handleMessage(SOAPMessageContext messageContext) {
Boolean outboundProperty = (Boolean) messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outboundProperty.booleanValue()) {
// I think I need to add something here but I dont know what
} else {}
return true;
}
我有私钥:myportal.key,公钥:portal.cer。
没有身份验证,我得到了:
javax.xml.ws.soap.SOAPFaultException: An error was discovered processing the <wsse:Security> header
答案 0 :(得分:0)
您可以通过以下方式获得帮助
System.setProperty("javax.net.debug","all");
如果密钥是自签名的,那么您可能还需要设置TrustStore
属性。