无法在KSOAP在android的序列化问题序列化、问题、KSOAP、android

2023-09-14 00:05:30 作者:醉千墨

我在我的应用程序中使用SOAP服务,因为当我打电话SOAP服务它抛出一些无法序列化的问题:

  SoapObject请求=新SoapObject(命名空间METHOD_NAME);
     SoapObject认证=新SoapObject(命名空间认证);
     的PropertyInfo usrid =新的PropertyInfo();
     usrid.setName(为LoginID);
     usrid.setValue(蛰);
     usrid.setType(为String.class);
     authentication.addProperty(usrid);

     的PropertyInfo通=新的PropertyInfo();
     pass.setName(密码);
     pass.setValue(字符串);
     pass.setType(为String.class);
     authentication.addProperty(通);

     request.addSoapObject(认证);

     的PropertyInfo号=新的PropertyInfo();
     no.setName(否);
     no.setValue(无);
     no.setType(为String.class);
     //authentication.addProperty(no);
     request.addProperty(海峡,数);

     SoapSerializationEnvelope包=新SoapSerializationEnvelope(SoapEnvelope.VER11);
     envelope.setOutputSoapObject(要求);
     envelope.dotNet = TRUE;
     HttpTransportSE androidHttpTransport =新HttpTransportSE(URL);
     尝试
     {
          androidHttpTransport.call(SOAP_ACTION,包);
          对象result =(对象)envelope.getResponse(); --------->此处我得到空指针。
          Log.i(对myApp,result.toString());
          的System.out.println(subbu =+ result.toString());
     }
 

我的要求结构为:

 <认证>
    <为LoginID>字符串< /为LoginID>
    <密码>字符串< /密码>
< /认证>
<不>字符串< /否GT;
 

我收到错误消息:

 了java.lang.RuntimeException:无法序列:否:
 
ksoap2 android

解决方案

在我看来,你在写你的code应该不能编译:

 的PropertyInfo号=新的PropertyInfo();
no.setName(否);
no.setValue(无);
no.setType(为String.class);
//authentication.addProperty(no);
request.addProperty(海峡,数);
 

如果你清楚的意思是:

 的PropertyInfo号=新的PropertyInfo();
nos.setName(否);
nos.setValue(无);
nos.setType(为String.class);
//authentication.addProperty(nos);
request.addProperty(海峡,数);
 

总之,我觉得这是一个错字,而你的真实code您没有提出这个错误。 因此,要回答你的问题,你应该告诉哪一个是空对象。这是不可能的,从你提供的code段猜。 使用断点和调试模式运行应用程序。然后给有关空对象信息。 此外,展示您的WSDL会有很大的帮助。

I am using SOAP services in my application,in that when i am calling SOAP services it throwing some cannot serialization problem:

     SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);           
     SoapObject authentication = new SoapObject(NAMESPACE,"authentication");
     PropertyInfo usrid =new PropertyInfo();
     usrid.setName("LoginID");
     usrid.setValue("sting");
     usrid.setType(String.class);
     authentication.addProperty(usrid);        

     PropertyInfo pass =new PropertyInfo();
     pass.setName("Password");
     pass.setValue("string");
     pass.setType(String.class);
     authentication.addProperty(pass);  

     request.addSoapObject(authentication);

     PropertyInfo nos =new PropertyInfo();
     no.setName("No");
     no.setValue(no);
     no.setType(String.class);
     //authentication.addProperty(no);
     request.addProperty("Str", nos);

     SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
     envelope.setOutputSoapObject(request);
     envelope.dotNet=true;    
     HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); 
     try
     { 
          androidHttpTransport.call(SOAP_ACTION,envelope);
          Object result=(Object)envelope.getResponse(); --------->Here i am getting nullpointer.
          Log.i("myApp",result.toString());         
          System.out.println("subbu="+result.toString());
     }

My request Structure is :

<authentication>
    <LoginID>string</LoginID>
    <Password>string</Password>
</authentication>
<No>string</No>

I am receiving the error message:

java.lang.RuntimeException: Cannot serialize:No:

解决方案

In my opinion your code should not compile as you are writing:

PropertyInfo nos =new PropertyInfo();
no.setName("No");
no.setValue(no);
no.setType(String.class);
//authentication.addProperty(no);
request.addProperty("Str", nos);

Where you clearly meant:

PropertyInfo nos =new PropertyInfo();
nos.setName("No");
nos.setValue(no);
nos.setType(String.class);
//authentication.addProperty(nos);
request.addProperty("Str", nos);

Anyway, i feel like this is a typo and that in your real code you didn't make this error. So to answer your question, you should tell which one is the null object. It is not possible to guess it from the code snippet you provided. Use a breakpoint and run your application in debug mode. Then give info about the null object. Also, showing your WSDL would be of great help.