我正在开发基于肥皂的应用程序。
当我向服务器请求时,我得到了类转换异常..
我的课看起来像..
package com.example.cafezeeapplication;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.StringReader;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xml.sax.InputSource;
import android.util.Log;
public class SaopCall {
SaopCall()
{
}
public final String SOAP_ACTION = "http://tempuri.org/OnlineStatus";
public final String OPERATION_NAME = "OnlineStatus";
public final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";
public final String SOAP_ADDRESS = "http://www.ebidmanagerdemo.com/gjHouseOnline/xml/XMLDataService.asmx";
InputStream is;
String data;
public String Call()
{
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME);
PropertyInfo pi=new PropertyInfo();
// request.addProperty("CafeName", "Cyber Cafe Name");
//
// request.addProperty("FromDate", "2012-03-01");
//
// request.addProperty("ToDate", "2013-06-03");
pi.setName("CafeName");
pi.setValue("Cyber Cafe Name");
pi.setType(String.class);
request.addProperty(pi);
pi=new PropertyInfo();
pi.setName("FromDate");
pi.setValue("2012-03-01");
pi.setType(String.class);
request.addProperty(pi);
pi=new PropertyInfo();
pi.setName("ToDate");
pi.setValue("2013-06-03");
pi.setType(String.class);
request.addProperty(pi);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
SoapObject response=null;
try
{
httpTransport.call(SOAP_ACTION, envelope);
response = (SoapObject) envelope.getResponse();
//data="count is"+response.getPropertyCount();
int elementCount ;
try{
SoapObject soapObjectGetProperty=(SoapObject) response.getProperty("OnlineStatusResult");
elementCount = soapObjectGetProperty.getAttributeCount();
data="count is"+elementCount;
}
catch(Exception e)
{
data=e.toString();
}
// data=soapObjectGetProperty.getProperty("MachineIP").toString();
//
// Log.i("count", data);
// if (elementCount > 0) {
// String element;
//
// for (int i = 0; i < elementCount; i++) {
//
//
// Log.i("Element count",""+ elementCount);
// element = response.getProperty(i).toString();
// if(element.equals("MachineIP"))
//
// Log.d("This is an element", Integer.toString(i)
// + " --" + element);
//
//
// }
// }
//
//
//
//
//Log.i(response.get," "+ response.getPropertyCount());
if(data==null)
{
data="helllo";
}
//
//data="count:"+response.getPropertyCount()+" "+response.getPropertyAsString(1);
//
//
// is = new ByteArrayInputStream(data.getBytes());
}
catch (Exception exception)
{
//response=exception.toString();
exception.printStackTrace();
data=exception.toString();
}
return data;
}
}
是我的网络服务响应问题吗?我的代码有什么问题???
谢谢大家的回复...