报错: Unable to sendViaPost to url[http://192.168.11.79:9001/Service.svc] org.apache.axis2.AxisFault: Transport error: 415 Error: Cannot process the message because the content type ‘application/soap+xml; charset=UTF-8’ was not the expected type ‘text/xml; charset=utf-8’. at org.apache.axis2.transport.http.impl.httpclient3.HTTPSenderImpl.handleResponse(HTTPSenderImpl.java:343) at org.apache.axis2.transport.http.impl.httpclient3.HTTPSenderImpl.sendViaPost(HTTPSenderImpl.java:213) at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:121) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:403) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:234) at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:431) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:399) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225) at org.apache.axis2.client.OperationClient.execute(OperationClient.java:150) at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:533) at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:509)
解析:SOAP v1.1 uses text/xml while SOAP v1.2 uses application/soap+xml.
解决:将v1.2换成v1.1
如果是相反的报错:Cannot process the message because the content type ‘application/soap+xml; charset=UTF-8’ was not the expected type ‘text/xml; charset=utf-8’. 则将v1.1改为v1.2
报错: 由于 ContractFilter 在 EndpointDispatcher 不匹配,因此 Action 为“”的消息无法在接收方处理。这可能是由于协定不匹配(发送方和接收方 Action 不匹配)或发送方和接收方绑定/安全不匹配。请检查发送方和接收方是否具有相同的协定和绑定(包括安全要求,如 Message、Transport、None)。
解析:用的SOAP1.1,在调用服务时必须在http的请求头加上:SOAPAction的值;
解决:options.setAction(“目标的TargetNameSpace”+“调用的方法名”);
|