我正在尝试使用 ksoap2-android 进行soap调用,服务器期望soap请求如下所示。
<?xml version="1.0" encoding="UTF-8" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<hilo:getHLPredAndMetadata xmlns:hilo="http://opendap.co-ops.nos.noaa.gov/axis/webservices/highlowtidepred/wsdl">
<stationId xmlns="">8454000</stationId>
<beginDate xmlns="">20060920 00:00</beginDate>
<endDate xmlns="">20060922 23:59</endDate>
<datum xmlns="">0</datum>
<unit xmlns="">0</unit>
<timeZone xmlns="">0</timeZone>
</hilo:getHLPredAndMetadata>
</soapenv:Body>
</soapenv:Envelope>
但添加属性后,我得到以下输出:
<?xml version="1.0" encoding="UTF-8" ?>
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
<v:Body>
<n0:getHLPredAndMetadata id="o0" c:root="1" xmlns:n0="http://opendap.co-ops.nos.noaa.gov/axis/webservices/highlowtidepred/wsdl">
<stationId i:type="d:string">8722669</stationId>
<beginDate i:type="d:string">20101101 00:00</beginDate>
<endDate i:type="d:string">20101101 23:00</endDate>
<datum i:type="d:int">0</datum>
<unit i:type="d:int">0</unit>
<timeZone i:type="d:int">0</timeZone>
</n0:getHLPredAndMetadata>
</v:Body>
</v:Envelope>
来源非常直接。拨打电话后,我收到以下错误:
11-02 03:01:01.151: ERROR/NoaaTideSoap(389): unexpected type (position:END_DOCUMENT null@1:0 in java.io.InputStreamReader@44eff1b8)
11-02 03:01:01.151: ERROR/NoaaTideSoap(389): org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null@1:0 in java.io.InputStreamReader@44eff1b8)
11-02 03:01:01.151: ERROR/NoaaTideSoap(389): at org.kxml2.io.KXmlParser.exception(KXmlParser.java:245)
11-02 03:01:01.151: ERROR/NoaaTideSoap(389): at org.kxml2.io.KXmlParser.nextTag(KXmlParser.java:1365)
11-02 03:01:01.151: ERROR/NoaaTideSoap(389): at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:126)
11-02 03:01:01.151: ERROR/NoaaTideSoap(389): at org.ksoap2.transport.Transport.parseResponse(Transport.java:63)
11-02 03:01:01.151: ERROR/NoaaTideSoap(389): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:100)
由于 KSOAP 问题,我不确定天气是否会出现此错误。我看不到我正在调用的服务返回的响应。
我的想法是该服务正在使用前缀“hilo”,就像他们在此处指定的那样:
我的电话看起来像:
此外,在他们期望的属性中:
8454000
而且态度又不一样了
8722669
有谁知道如何使用 KSOAP 设置这些值?
下面是一个代码片段:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("stationId","8722669");
request.addProperty("beginDate","20101101 00:00");
request.addProperty("endDate","20101101 23:00");
request.addProperty("datum",0);
request.addProperty("unit",0);
request.addProperty("timeZone",0);
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
//soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(request);
AndroidHttpTransport aht = new AndroidHttpTransport(URL);
aht.setXmlVersionTag("<?xml version=\"1.0\" encoding= \"UTF-8\" ?>");
aht.debug = true;
提前致谢