0

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:
subburaj
  • 161
  • 2
  • 15

1 Answers1

0

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.

andreapier
  • 2,958
  • 2
  • 38
  • 50
  • Hi andreapier..Actually the no is a string String no=getIntent().getStringExtra("no"); which i am getting from previos screen. – subburaj May 19 '12 at 10:00
  • Look a the code... you are overwriting the String no with a PropertyInfo no = new PropertyInfo() as i pointed out in my answer. – andreapier May 19 '12 at 10:03
  • oh andreapier..sory now i have edited the code..Now i solved serialize problem,now i am receiving the error SoapFault - faultcode: 'soap:Server' faultstring: 'System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object. – subburaj May 19 '12 at 10:17
  • Hi andreapier..i cant able to post my original code.if i did so i ahve to face some problem..thats y i edit code which resembles my own..in that sometimes may be editting problem thats y this much difficulty..now i have edited my post where i getting null pointer.. – subburaj May 19 '12 at 10:31
  • I cannot help you any more if you do not make a rasonable good post. It is simply IMPOSSIBLE that envelope is not null when you call envelope.setOutputSoapObject(request); and then it becames null when you call envelope.getResponse();. So there are 2 possibilities: a) the null pointer exception doesn't came from the specified line (ie: from the following one). b) in your real code you are overwriting the envelope object. I think you are messying things when you create code samples here. Please take some minutes to make a real-case example. Otherwise i'll delete my answer and will not help. – andreapier May 19 '12 at 10:42