我必须与Soap Web服务进行通信,目前我通过使用Java库Axis2构建的客户端来使用它,一切进展顺利,但我需要为Apache CXF迁移此客户端,因为我们通过Apache有其他客户端CXF,当我们在同一个类路径中使用Axis2和Apache Cxf时,由于两个库都使用不同的XmlSchema实现,我们会遇到一些冲突。
问题是当使用Apache Cxf时,响应是以html而不是soap发送的,因为你可以通过我们收到的这个堆栈跟踪看到:
javax.xml.ws.soap.SOAPFaultException: Response was of unexpected text/html ContentType. Incoming portion of HTML stream: <html>
...
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:157)
...
at org.apache.cxf.interceptor.StaxInInterceptor.handleMessage(StaxInInterceptor.java:84)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:835)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1614)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1504)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1310)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:628)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:565)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:474)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:377)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:330)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
.. 27 more
我检查了这两个请求,两者看起来都像你在这里看到的一样:
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Header>
<axis2ns10:login xmlns:axis2ns10="http://auth.smssp.atech.br">LOGIN</axis2ns10:login>
<axis2ns11:password xmlns:axis2ns11="http://auth.smssp.atech.br">PASSWORD</axis2ns11:password>
<axis2ns12:sistema xmlns:axis2ns12="http://auth.smssp.atech.br">SYSTEM</axis2ns12:sistema>
</soapenv:Header>
<soapenv:Body>
<ser:pesquisar xmlns:ns2="http://service.smssp.atech.br">
<ser:numeroCNS>11111111</ser:numeroCNS>
<ser:carregarObjetoCompleto>true</ser:carregarObjetoCompleto>
</ser:pesquisar>
</soapenv:Body>
</soapenv:Envelope>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<login xmlns="http://auth.smssp.atech.br">LOGIN</login>
<password xmlns="http://auth.smssp.atech.br">PASSWORD</password>
<sistema xmlns="http://auth.smssp.atech.br">SYSTEM</sistema>
</soap:Header>
<soap:Body>
<ns2:pesquisar xmlns="http://domain.smssp.atech.br/xsd" xmlns:ns2="http://service.smssp.atech.br" xmlns:ns3="http://searchFilter.infra.smssp.atech.br/xsd">
<ns2:numeroCNS>11111111</ns2:numeroCNS>
<ns2:carregarObjetoCompleto>true</ns2:carregarObjetoCompleto>
</ns2:pesquisar>
</soap:Body>
</soap:Envelope>
知道问题是什么吗?
最诚挚的问候, 若昂