我正在尝试使用 android 应用程序访问 Web 服务。我收到以下异常,对此我没有任何想法。请帮忙:
09-01 11:21:29.873: WARN/System.err(921): SoapFault - faultcode: 'soapenv:Server' faultstring: 'com.hello.service.DataStore' faultactor: 'null' detail: org.kxml2.kdom.Node@44e9a320
09-01 11:21:29.883: WARN/System.err(921): at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:112)
09-01 11:21:29.883: WARN/System.err(921): at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:137)
09-01 11:21:29.883: WARN/System.err(921): at org.ksoap2.transport.Transport.parseResponse(Transport.java:63)
09-01 11:21:29.883: WARN/System.err(921): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:100)
09-01 11:21:29.883: WARN/System.err(921): at com.example.HelloTestActivity.onCreate(HelloTestActivity.java:64)
09-01 11:21:29.883: WARN/System.err(921): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-01 11:21:29.883: WARN/System.err(921): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-01 11:21:29.883: WARN/System.err(921): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-01 11:21:29.883: WARN/System.err(921): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-01 11:21:29.883: WARN/System.err(921): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-01 11:21:29.883: WARN/System.err(921): at android.os.Handler.dispatchMessage(Handler.java:99)
09-01 11:21:29.883: WARN/System.err(921): at android.os.Looper.loop(Looper.java:123)
09-01 11:21:29.894: WARN/System.err(921): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-01 11:21:29.894: WARN/System.err(921): at java.lang.reflect.Method.invokeNative(Native Method)
09-01 11:21:29.894: WARN/System.err(921): at java.lang.reflect.Method.invoke(Method.java:521)
09-01 11:21:29.894: WARN/System.err(921): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-01 11:21:29.894: WARN/System.err(921): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-01 11:21:29.904: WARN/System.err(921): at dalvik.system.NativeStart.main(Native Method)
该请求甚至没有命中服务器。它仅在调用时失败。以下是我的网络服务调用代码:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv=(TextView)findViewById(R.id.hello);
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
DataStore t=new DataStore("samsung");
PropertyInfo pi = new PropertyInfo();
pi.setName("name");
pi.setValue(t);
pi.setType(t.getClass());
request.addProperty(pi);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
envelope.setAddAdornments(false);
envelope.implicitTypes=true;
envelope.addMapping(NAMESPACE, "DataStore",new DataStore().getClass());
AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(URL);
try{
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject response=(SoapObject) envelope.getResponse();
String Name = response.getProperty(0).toString();
tv.setText("Response :" + Name);
} catch (Exception e) {
e.printStackTrace();
}
}
以下是我的java bean:
public class DataStore implements KvmSerializable
{
private static final String NAMESPACE = "http://service.hello.com";
private String path;
public String getPath() {
return path;
}
private void setPath(String path) {
this.path = path;
}
public DataStore(String path) {
this.path = path;
}
public DataStore() {
// TODO Auto-generated constructor stub
}
public Object getProperty(int arg0) {
Log.d("KVM","gp");
switch(arg0)
{
case 0:
Log.d("KVM","after");
return path;
}
return null;
}
public int getPropertyCount() {
Log.d("KVM","gpc");
return 1;
}
public void getPropertyInfo(int index, Hashtable arg1, PropertyInfo info) {
Log.d("KVM","gpi "+index);
switch(index)
{
case 0:
info.type = PropertyInfo.STRING_CLASS;
info.name = "path";
break;
default:break;
}
}
public void setProperty(int index, Object value) {
Log.d("KVM","sp");
switch(index)
{
case 0:
path = (String)value;
break;
default:
break;
}
}
public void register(SoapSerializationEnvelope cm) {
// TODO Auto-generated method stub
Log.d("KVM","register");
cm.addMapping(NAMESPACE, "DataStore", this.getClass());
}
}
请帮我解决这个问题。
问候, 拉胡尔