Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
433 views
in Technique[技术] by (71.8m points)

ksoap2 - Cannot serialize issue in KSOAP in android

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:
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...