Note that there are some explanatory texts on larger screens.

plurals
  1. POWeb Service Android Application : Cannot serialize 1.0
    primarykey
    data
    text
    <p><strong>P.S</strong> : I have looked at similar questions but haven't been able to understand what to do. They talk about using a marshal class, which I can't seem to understand.<br></p> <p>I am creating an <strong>Android application</strong> to <strong>consume a JAX-WS</strong>. I am using the <strong>ksoap-2</strong> library for the same.<br></p> <p>I take the inputs from the user in a series of text fields and pass these onto WebService activity. <br> Here in the onCreate method I call the web service after setting up the soap object :<br></p> <pre><code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get the message from the intent Intent intent = getIntent(); Bundle extras = intent.getExtras(); String cropName = extras.getString(AndroidWSClient.CROP_NAME); float area = extras.getFloat(AndroidWSClient.AREA); </code></pre> <p>Similarly I get the some names of fertilizers and add them to an ArrayList called fertilizerList. i also get three more values in a similar manner.<br></p> <pre><code>SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); // Add parameters to the SOAP object // cropName PropertyInfo propInfo = new PropertyInfo(); propInfo.name = "cropName"; propInfo.type = PropertyInfo.STRING_CLASS; request.addProperty(propInfo, cropName); System.out.println("!!!! Success with cropName !!!"); // Area propInfo = new PropertyInfo(); propInfo.setName("area"); propInfo.setType(Double.class); request.addProperty(propInfo, area); System.out.println("!!!! Success with area !!!"); // fertilizerList propInfo = new PropertyInfo(); propInfo.setName("fertilizerList"); propInfo.setType(ArrayList.class); request.addProperty(propInfo, fertilizerList); System.out.println("!!!! Success with fertilizerList !!!"); // N value propInfo = new PropertyInfo(); propInfo.setName("nitrogen"); propInfo.setType(Integer.class); request.addProperty(propInfo, n); System.out.println("!!!! Success with N !!!"); </code></pre> <p>Here I create the soap object and properties to it.<br> <strong>I need to pass multiple parameters to my Web Service, so the order in which I add these properties is the order in which they'll appear as parameters to the web service, right ?</strong><br> I then send out the request to the web service : <br></p> <pre><code>// Send out the request to the web service SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); System.out.println("created envelope!"); envelope.setOutputSoapObject(request); System.out.println("Reached set output object"); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); System.out.println("Reached HttpTransport layer"); try { androidHttpTransport.call(SOAP_ACTION, envelope); SoapPrimitive resultsRequestSOAP = (SoapPrimitive) envelope.getResponse(); TextView textView = new TextView(this); textView.setTextSize(40); System.out.println(resultsRequestSOAP.toString()); textView.setText(resultsRequestSOAP.toString()); // Set the text view as the activity layout setContentView(textView); } catch (Exception e) { e.printStackTrace(); } </code></pre> <p>Here is the output from the logcat :<br></p> <pre><code> 07-11 05:37:32.782: I/System.out(1698): !!!! Success with cropName !!! 07-11 05:37:32.782: I/System.out(1698): !!!! Success with area !!! 07-11 05:37:32.792: I/System.out(1698): !!!! Success with fertilizerList !!! 07-11 05:37:32.792: I/System.out(1698): !!!! Success with N !!! 07-11 05:37:32.872: I/System.out(1698): created envelope! 07-11 05:37:32.872: I/System.out(1698): Reached set output object 07-11 05:37:32.912: I/System.out(1698): Reached HttpTransport layer 07-11 05:37:33.012: W/System.err(1698): java.lang.RuntimeException: Cannot serialize: 1.0 07-11 05:37:33.012: W/System.err(1698): at org.ksoap2.serialization.SoapSerializationEnvelope.writeElement(SoapSerializationEnvelope.java:629) 07-11 05:37:33.022: W/System.err(1698): at org.ksoap2.serialization.SoapSerializationEnvelope.writeProperty(SoapSerializationEnvelope.java:613) 07-11 05:37:33.032: W/System.err(1698): at org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(SoapSerializationEnvelope.java:582) 07-11 05:37:33.032: W/System.err(1698): at org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(SoapSerializationEnvelope.java:566) 07-11 05:37:33.062: W/System.err(1698): at org.ksoap2.serialization.SoapSerializationEnvelope.writeElement(SoapSerializationEnvelope.java:623) 07-11 05:37:33.072: W/System.err(1698): at org.ksoap2.serialization.SoapSerializationEnvelope.writeBody(SoapSerializationEnvelope.java:547) 07-11 05:37:33.072: W/System.err(1698): at org.ksoap2.SoapEnvelope.write(SoapEnvelope.java:192) 07-11 05:37:33.092: W/System.err(1698): at org.ksoap2.transport.Transport.createRequestData(Transport.java:74) 07-11 05:37:33.092: W/System.err(1698): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:58) 07-11 05:37:33.112: W/System.err(1698): at com.example.androidwsclient.WebServiceActivity.onCreate(WebServiceActivity.java:99) 07-11 05:37:33.112: W/System.err(1698): at android.app.Activity.performCreate(Activity.java:5104) 07-11 05:37:33.132: W/System.err(1698): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload