我很困惑,试图在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