Java 我正试图通过使用下面的代码调用webservice来获取城市列表

Java 我正试图通过使用下面的代码调用webservice来获取城市列表,java,android,asp.net,web-services,ksoap2,Java,Android,Asp.net,Web Services,Ksoap2,这是我得到的一个例外 org.xmlpull.v1.XmlPullParserException:意外标记(位置:TEXT[{“Id”:“57”,“Tit…@1:275 in java.io。InputStreamReader@b629f48) 使用以下代码 public String SuggestCity (String CityName) { SoapObject soapObject=new SoapObject(Wsdl_Target_NameSpace,Ope

这是我得到的一个例外

org.xmlpull.v1.XmlPullParserException:意外标记(位置:TEXT[{“Id”:“57”,“Tit…@1:275 in java.io。InputStreamReader@b629f48)

使用以下代码

public String SuggestCity  (String CityName)  {
    SoapObject soapObject=new       SoapObject(Wsdl_Target_NameSpace,Operation_Name);
    PropertyInfo propertyInfo=new PropertyInfo();
    propertyInfo.setName("tryValue");
    propertyInfo.setValue(CityName);
    propertyInfo.setType(String.class);
    soapObject.addProperty(propertyInfo);
    SoapSerializationEnvelope serializationEnvelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
    serializationEnvelope.setOutputSoapObject(soapObject);
    serializationEnvelope.dotNet=true;
    String response=null;
    HttpTransportSE androidHttpTransport = new HttpTransportSE(Soap_Adrress);
   //androidHttpTransport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
    androidHttpTransport.debug=true;


    try{
        androidHttpTransport.call(Soap_Action, serializationEnvelope);
        SoapPrimitive result = (SoapPrimitive) serializationEnvelope.getResponse();
        response=result.toString();
        Log.d("asdf",result.toString());
        //response=androidHttpTransport.responseDump;
    }
   catch (Exception e){
        Log.d("Haha",e.toString());
    }
    return response;

}
publicstringsuggestcity(stringcityname){
SoapObject SoapObject=新的SoapObject(Wsdl\u目标\u命名空间、操作\u名称);
PropertyInfo PropertyInfo=新的PropertyInfo();
propertyInfo.setName(“tryValue”);
propertyInfo.setValue(CityName);
propertyInfo.setType(String.class);
addProperty(propertyInfo);
SoapSerializationEnvelope serializationEnvelope=新的SoapSerializationEnvelope(SoapEnvelope.VER11);
serializationEnvelope.setOutputSoapObject(soapObject);
serializationEnvelope.dotNet=true;
字符串响应=null;
HttpTransportSE androidHttpTransport=新的HttpTransportSE(Soap_adress);
//androidHttpTransport.setXmlVersionTag(“”);
androidHttpTransport.debug=true;
试一试{
调用(Soap_操作,序列化信封);
SoapPrimitive结果=(SoapPrimitive)serializationEnvelope.getResponse();
response=result.toString();
Log.d(“asdf”,result.toString());
//response=androidHttpTransport.responseDump;
}
捕获(例外e){
Log.d(“哈哈”,例如toString());
}
返回响应;
}

有什么想法吗?

您正在尝试将结果(即JSON)解析为XML。您正在调用的服务是WCF服务吗?这是我正在使用的url,如何删除此异常???@RichardMosselveld可能与Thanx@Richard Mosselveld重复,通过ksoap2有什么方法吗???不,不幸的是我没有那么多ksoap2知识。尝试搜索json/ksoap2的组合