2012-07-20 62 views
1

我正在使用Java 6,Spring 3.0.5.RELEASE,Apache CXF 2.4.1,JBoss 5.1。 我的配置適用於Tomcat 7,但在JBoss上,當我向服務器發送SOAP消息時,我得到了NotImplementedException。JBoss 5.1上的CXF安全性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) 

的applicationContext.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" /> 

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"); 
    } 
} 
} 

回答

1

最後它的工作原理。 我將apache cxf版本更改爲2.1.10,並更改了一些依賴關係的範圍。

<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>