目标服务.net写的貌似,
http://www.wopos.com/webservice/idcard.asmx
调用的HTTP:POST /webservice/idcard.asmx HTTP/1.1
Content-Type: text/xml; charset=UTF-8
SOAPAction: "http://tempuri.org/WhereAreYou"
User-Agent: Axis2
Host: www.wopos.com
Transfer-Encoding: chunked返回HTTP/1.1 400 Bad Request
Date: Wed, 12 Mar 2008 09:31:33 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Length: 0好像是因为请求缺少XML
期待的请求:POST /webservice/idcard.asmx HTTP/1.1
Host: www.wopos.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/WhereAreYou"<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <WhereAreYou xmlns="http://tempuri.org/">
      <IDcardNo>string</IDcardNo>
    </WhereAreYou>
  </soap:Body>
</soap:Envelope>使用Axis调用时会与HTTP信息一同传递XML:
Content-Type: application/soap+xml; charset=UTF-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.4
Host: www.wopos.com
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Content-Length: 451<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:WhereAreYou soapenv:encodingStyle="http://www.w3.org/2003/05/soap-encoding" xmlns:ns1="http://tempuri.org/">
<IDcardNo xsi:type="xsd:string">230102198508201610</IDcardNo>
</ns1:WhereAreYou>
</soapenv:Body>
</soapenv:Envelope>而Axis2则只传递HTTP信息
如何才能让Axis2同发送HTTP请求和XML
附代码:RPCServiceClient serviceClient = new RPCServiceClient();Options options = serviceClient.getOptions();
options.setSoapVersionURI(Constants.URI_SOAP11_HTTP);EndpointReference targetEPR = new EndpointReference(
"http://www.wopos.com/webservice/idcard.asmx");
options.setTo(targetEPR);
options.setAction("http://tempuri.org/WhereAreYou");// QName of the target method
QName opAddEntry = new QName("http://tempuri.org/", "WhereAreYou");// Constructing the arguments array for the method invocation
Object[] opAddEntryArgs = new Object[] { "XXXXXXX" };
Class[] returnTypes = new Class[] { String.class };// Invoking the method
Object[] response = serviceClient.invokeBlocking(opAddEntry, opAddEntryArgs, returnTypes);
System.out.println(response[0]);(也用过AXIOM方式调用,问题一样,没发XML,使用Axis明明会一起发送的...)