在CXF Dispatching vs SoapUI中使用MTOM时出现错误请求

时间:2014-02-13 14:29:58

标签: java soap cxf dispatch mtom

我正在尝试通过javax Dispatching mechanism发送以下请求:

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header/>
<env:Body>
    <RetrieveDocumentSetRequest xmlns="urn:ihe:iti:xds-b:2007">
        <DocumentRequest>
            <RepositoryUniqueId>1.3.6.1.4.1.21367.2011.2.3.7</RepositoryUniqueId>
            <DocumentUniqueId>1.42.20131104173322.13</DocumentUniqueId>
        </DocumentRequest>
    </RetrieveDocumentSetRequest>
</env:Body>

到此终点:http://ihexds.nist.gov:12080/tf6/services/xdsrepositoryb
WSDL可在此处获取:http://ihexds.nist.gov:12080/tf6/services/xdsrepositoryb?wsdl

此端点需要启用并强制MTOM。使用SOAP UI这不是问题,因为我可以启用并强制MTOM。我如何从代码中执行此操作?我只能“启用”但不会强制MTOM。

这是我的相关代码:

Service service = Service.create(new QName(XDS_REPOSITORY_NAMESPACE, XDS_REPOSITORY_SERVICE));
QName port = new QName(XDS_REPOSITORY_NAMESPACE, XDS_REPOSITORY_PORT);
service.addPort(port, SOAPBinding.SOAP12HTTP_MTOM_BINDING, XDS_REPOSITORY_ENDPOINT);
AddressingFeature addrFt = new AddressingFeature(true, true);
MTOMFeature mtomFt = new MTOMFeature(true);
Dispatch<SOAPMessage> dispatch = service.createDispatch(port, SOAPMessage.class, Service.Mode.MESSAGE, addrFt, mtomFt);
dispatch.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, "urn:ihe:iti:2007:RegistryStoredQuery");
SOAPBinding binding = (SOAPBinding)dispatch.getBinding();
Object soapResponse = dispatch.invoke(soapRequest);

这会产生以下错误(在TomEE上部署的应用程序中运行时):

org.apache.cxf.transport.http.HTTPException: HTTP response '400: Bad Request' when communicating with http://ihexds.nist.gov:12080/tf6/services/xdsrepositoryb
    org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1626)
    org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1537)
    org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1445)
    org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
    org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:660)
    org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
    org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
    org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:541)
    org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:474)
    org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:377)
    org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:330)
    org.apache.cxf.endpoint.ClientImpl.invokeWrapped(ClientImpl.java:365)
    org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:385)
    org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:243)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)

0 个答案:

没有答案