我很困惑,試圖在Android中使用kSOAP2來使用ColdFusion SOAP服務。這裏是我的調用測試方法我寫了一首歌的ColdFusion(只返回一個字符串)Java代碼:kSOAP XmlPullParserException
private static final String NAMESPACE = "http://www.sub.tv/MyService.cfc?WSDL";
private static String URL = "http://www.sub.tv/MyService.cfc";
private static final String METHOD_NAME = "TestMethod";
private static final String SOAP_ACTION = "http://www.sub.tv/MyService.cfc?method=TestMethod";
public void GetData() {
SoapPrimitive resultstring = null;
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo inputArgs = new PropertyInfo();
inputArgs.setName("ID");
inputArgs.setValue(1234);
inputArgs.setType(Integer.class);
request.addProperty(inputArgs);
SoapSerializationEnvelope soapenvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapenvelope.dotNet = false;
soapenvelope.setOutputSoapObject(request);
AndroidHttpTransport httptransport = new AndroidHttpTransport(URL);
//httptransport.debug = true;
try {
httptransport.call(SOAP_ACTION, soapenvelope);
resultstring = (SoapPrimitive) soapenvelope.getResponse();
} catch (Exception e) {
Log.d(DEBUG, e.getMessage());
}
}
,這裏是ColdFusion的測試方法我已經寫了只返回一個字符串:
<cfcomponent displayname="test_web_service" namespace="http://www.sub.tv">
<cffunction name="TestMethod" returnType = "string" access="remote" description="Test Method">
<cfargument name="ID" type="numeric">
<cfreturn "hello" />
</cffunction>
</cfcomponent>
我得到的錯誤,當我執行上面的Java代碼如下:
org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope (position:START_TAG <html>@2:44 in [email protected])
我懷疑問題的原因可能是我在SOAP_ACTION規定,但URL,如F正如我所知,這是調用ColdFusion SOAP Web服務方法的正確方法。在瀏覽器中執行該URL會返回預期的結果。我試過排除在該URL的查詢字符串中的方法調用,但我仍然得到相同的錯誤。
任何幫助將不勝感激。
感謝您的時間,
託尼
喜道格,你的幫助非常非常感謝。我確實嘗試將類型更改爲Double.class,但不幸的是沒有工作 - 我仍然收到相同的錯誤。正如Miguel-F提到的,我已經將我的解析引擎更改爲SAX,以便使用來自ColdFusion的XML響應,但將繼續尋求解決方案以使kSOAP正常工作。我將嘗試接下來使用kSOAP來使用WCF服務。 – tony