当我尝试在需要MTOM附加文件的生产环境中使用服务时出现以下错误。
我已在CXF中创建了客户端,并以下列方式启用了MTOM。
service= new FileTransferService();
//service.setHandlerResolver(new JaxWsHandlerResolver());
port=service.getFileTransferServicePort();
BindingProvider bp = (BindingProvider) port;
SOAPBinding binding = (SOAPBinding) bp.getBinding();
binding.setMTOMEnabled(true);
我得到的错误是
javax.xml.ws.soap.SOAPFaultException: BEA-382116: There should be exactly one MIME attachment with Content-ID = '3fbc960c-ac11-4bdb-b699-cdda584344a8@http://cxf.apache.org/'.
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:211)
at com.sun.proxy.$Proxy28.transferFileService(Unknown Source)
at com.file.transfer.SoaTransfer.transferToWebService(SoaTransfer.java:200)
at com.file.transfer.SoaTransfer.run(SoaTransfer.java:267)
at java.lang.Thread.run(Thread.java:767)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:939)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:963)
at java.lang.Thread.run(Thread.java:767)
Caused by: org.apache.cxf.binding.soap.SoapFault: BEA-382116: There should be exactly one MIME attachment with Content-ID = '3fbc960c-ac11-4bdb-b699-cdda584344a8@http://cxf.apache.org/'.
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:70)
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:35)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:96)
at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:65)
at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:34)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:429)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1988)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1824)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:583)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:276)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:222)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:170)
... 7 more
然而当我删除我为另一个仅从Host WebService下载文件的客户端WebService添加的cxf jar时,此服务正常工作,该文件也被添加并作为附件传输
以下是我为了使服务工作而移除的罐子列表
cxf-2.0.6.jar , geronimo-activation_1.1_spec-1.0.2.jar , geronimo-annotation_1.0_spec-1.1.1.jar , geronimo-javamail_1.4_spec-1.3.jar , jaxb-api-2.0.jar , jaxb-impl-2.0.5.jar , jaxb-xjc-2.0.jar , neethi-3.0.2.jar , spring.jar , stax-utils-20060502.jar , velocity-1.4.jar , velocity-dep-1.4.jar , wsdl4j-1.6.1.jar , wstx-asl-3.2.4.jar , xml-resolver-1.2.jar , XmlSchema-1.4.2.jar
修改
请注意我使用的cxf版本是2.0.6
答案 0 :(得分:0)
当服务将带有MTOM的附件发送到任何第三方Web服务时,问题出在cxf上。由于这个问题: - CXF MTOM producer for third party issue
升级到CXF 2.7.18解决了这个问题。