Pregunta

I need to generate a SoapObject. here is my code --

SoapObject request = new SoapObject(namespace, method);
SoapObject r = new SoapObject(namespace, "request");
r.addProperty("email", email);      
request.addSoapObject(r);

my code generates the following

   <Info xmlns=NAMESPACE > 
      <request>
     <email>id@gmail.com</email>
      </request>
   </Info>

but the request body needs to be like this

<con:Info>
     <!--Optional:-->
     <con:request>

        <typ:email>id@gmail.com</typ:email>

     </con:request>
  </con:Info>

what should i do to include that typ:'s equivalent in my code?

¿Fue útil?

Solución

The code you want to generate lacks namespace declarations, they are probably somewhere up in the tree.

The namespace for email seems to be different than the namespace for the rest. Your code needs to reflect that to generate equivalent XML.

p.s. You could try something like

PropertyInfo emailType = new PropertyInfo();
emailType.name = "email";
emailType.namespace = emailNamespace;
emailType.type = String.class;
r.addProperty(emailType, email);

kSOAP was written for J2ME, which does not support reflection, and it has some complexities to work around this. I don' think I can really recommend it on Android:

  • For simple cases, one could just use the DOM
  • For complex cases, a serialization library similar to GSON might make more sense (not sure if something similar to GSON exists for SOAP object serialization).
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top