0

我在我的应用程序中使用 SOAP 服务,因为当我调用 SOAP 服务时,它会引发一些无法序列化的问题:

     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());
     }

我的请求结构是:

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

我收到错误消息:

java.lang.RuntimeException: Cannot serialize:No:
4

1 回答 1

0

在我看来,您的代码不应在您编写时编译:

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

你明确的意思是:

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

无论如何,我觉得这是一个错字,在你的真实代码中你没有犯这个错误。
所以要回答你的问题,你应该告诉哪个是空对象。从您提供的代码片段中无法猜测它。
使用断点并在调试模式下运行您的应用程序。然后提供有关空对象的信息。
此外,显示您的 WSDL 也会有很大帮助。

于 2012-05-19T09:49:46.563 回答