1

我正在使用 WebLogic 8.1 clientgen工具生成所需的类来发送肥皂请求。我尝试连接的 Web 服务(基于 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();
}

Clientgen 工件:

     [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)
4

0 回答 0