我正在使用WebLogic 8.1 clientgen 工具生成发送soap请求所需的类。我尝试连接的Web Service(基于spring-ws)使用Wss4jSecurityInterceptor进行身份验证。配置如下所示:
<bean id="wss4jSecurityInterceptor"
class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
<property name="validationActions" value="UsernameToken" />
<property name="validationCallbackHandler" ref="passwordValidationHandler" />
</bean>
<bean id="passwordValidationHandler"
class="org.springframework.ws.soap.security.wss4j.callback.SimplePasswordValidationCallbackHandler">
<property name="users">
<props>
<prop key="${user}">${password}</prop>
</props>
</property>
</bean>
添加身份验证标头是否正确?
private BirtService_PortType port;
private init( String serviceUrl,String username,String password) throws IOException{
BirtService_Impl service;
try {
service = new BirtService_Impl( serviceUrl );
port = service.getBirtService_PortType();
//here authentication part
Stub stub = (Stub)port;
stub._setProperty(Stub.USERNAME_PROPERTY, username);
stub._setProperty(Stub.PASSWORD_PROPERTY, password);
} catch (IOException e) {
log.error("Error while creating BirtService_Impl",e);
throw e;
}
sendRequest();
}
[java] 17:35:05,193 ERROR BirtClient:56-Error ocurred
[java] java.rmi.RemoteException: SOAP Fault:javax.xml.rpc.soap.SOAPFaultException: No WS-Security header found
[java] Detail:
[java] null; nested exception is:
[java] javax.xml.rpc.soap.SOAPFaultException: No WS-Security header found
[java] at birt.wsclient.BirtService_PortType_Stub.birt(BirtService_PortType_Stub.java:31)
[java] at birt.ws.client.BirtClient.getReport(BirtClient.java:51)
[java] at birt.ws.client.Main.main(Main.java:31)
[java] Caused by: javax.xml.rpc.soap.SOAPFaultException: No WS-Security header found
[java] at weblogic.webservice.core.ClientDispatcher.receive(ClientDispatcher.java:314)
[java] at weblogic.webservice.core.ClientDispatcher.dispatch(ClientDispatcher.java:144)
[java] at weblogic.webservice.core.DefaultOperation.invoke(DefaultOperation.java:471)
[java] at weblogic.webservice.core.DefaultOperation.invoke(DefaultOperation.java:457)
[java] at weblogic.webservice.core.rpc.StubImpl._invoke(StubImpl.java:303)
[java] at birt.wsclient.BirtService_PortType_Stub.birt(BirtService_PortType_Stub.java:26)