1

我正在使用 Java 6、Spring 3.0.5.RELEASE、Apache CXF 2.4.1、JBoss 5.1。我的配置适用于 Tomcat 7,但在 JBoss 上,当我向服务器发送 SOAP 消息时,我得到了 NotImplementedException。

Service has thrown exception, unwinding now org.jboss.util.NotImplementedException
at org.jboss.ws.core.soap.SOAPPartImpl.appendChild(SOAPPartImpl.java:298)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:970)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:947)
at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:157)
at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMessage(ReadHeadersInterceptor.java:60)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:118)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:208)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:205)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:113)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:184)

应用程序上下文.xml

<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<import resource="classpath*:META-INF/cxf/cxf-extension-*.xml" />

<jaxws:endpoint id="myServiceEndPoint" implementor="#myService" address="/myService">
    <jaxws:inInterceptors>
        <bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
            <constructor-arg>
                <map>
                    <entry key="action" value="UsernameToken" />
                    <entry key="passwordType" value="PasswordDigest" />
                    <entry key="signaturePropFile" value="..." />
                    <entry key="passwordCallbackRef">
                        <ref bean="myPasswordCallback" />
                    </entry>
                </map>
            </constructor-arg>
        </bean>
    </jaxws:inInterceptors>
</jaxws:endpoint>

<bean id="myPasswordCallback" class="com.middleware.security.ServerPasswordCallback" />

服务器密码回调.java

import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
import org.apache.ws.security.WSPasswordCallback;

public class ServerPasswordCallback implements CallbackHandler {

     public void handle(Callback[] callbacks) throws IOException,
        UnsupportedCallbackException {

    WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];

    if (pc.getIdentifier().equals("nbi")) {
        pc.setPassword("123");
    }
}
}  
4

1 回答 1

1

At last it works. I changed apache cxf version to 2.1.10 and changed scope of some dependencies.

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-core</artifactId>
        <version>${cxf.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>${cxf.version}</version>
        <exclusions>
            <exclusion>
                <groupId>xml-resolver</groupId>
                <artifactId>xml-resolver</artifactId>
            </exclusion>
            <exclusion>
                <groupId>asm</groupId>
                <artifactId>asm</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-api</artifactId>
        <version>${cxf.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-ws-security</artifactId>
        <version>${cxf.version}</version>
        <scope>compile</scope>
        <exclusions>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>xalan</groupId>
                <artifactId>xalan</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache</groupId>
                <artifactId>serializer</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>xml-resolver</groupId>
        <artifactId>xml-resolver</artifactId>
        <version>1.2</version>
        <scope>provided</scope>
    </dependency>
    <!-- <dependency> -->
    <!-- <groupId>javax.xml.soap</groupId> -->
    <!-- <artifactId>saaj-api</artifactId> -->
    <!-- <version>1.3</version> -->
    <!-- </dependency> -->
    <!-- <dependency> -->
    <!-- <groupId>com.sun.xml.messaging.saaj</groupId> -->
    <!-- <artifactId>saaj-impl</artifactId> -->
    <!-- <version>1.3</version> -->
    <!-- </dependency> -->
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>2.1.13</version>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>
    <!-- <dependency> -->
    <!-- <groupId>javax.xml</groupId> -->
    <!-- <artifactId>jaxrpc-api-osgi</artifactId> -->
    <!-- <version>1.1-b01</version> -->
    <!-- </dependency> -->
    <dependency>
        <groupId>javax.xml.ws</groupId>
        <artifactId>jaxws-api</artifactId>
        <version>2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.axis</groupId>
        <artifactId>axis-jaxrpc</artifactId>
        <version>1.4</version>
        <scope>provided</scope>
    </dependency>
于 2012-07-20T16:22:42.370 回答