我正在尝试使用ksoap2-android进行肥皂调用,服务器期望肥皂请求如下所示。
<?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>
The Source非常直接。拨打电话后,我收到以下错误:
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;
提前致谢
答案 0 :(得分:0)
一堆事情:
androidHttpTransport.debug = true;
然后调试getResponse调用,看看你得到了什么。你应该有一个SoapObject或SoapPrimitive或SoapFault包含来自服务器的repsonse。将debug选项设置为true,您还将在bodyIn中看到响应的原始xml。这应该可以让你想出什么。
答案 1 :(得分:0)
如果Web服务是基于.NET的,请先设置断点,或者只是设置一条日志消息,以查看是否正确调用了Web服务。
我建议的另一件事是你使用一个复杂的对象作为参数而不是你要发送的所有这些参数。