Note that there are some explanatory texts on larger screens.

plurals
  1. POFormat of ksoap2 envelope not correct
    text
    copied!<p>Im trying to send a soap envelope to my .net webservice using ksoap2. Unfortunately the envelope it is creating, the webservice doesn't like. I tested this in soapUI and was getting the same return of just [] (JSON). Ksoap is generating:</p> <pre><code>&lt;v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;v:Header /&gt; &lt;v:Body&gt; &lt;getTest xmlns="http://www.carefusion.com/" id="o0" c:root="1"&gt; &lt;testint i:type="d:int"&gt;16875&lt;/testint&gt; &lt;/getTest&gt; &lt;/v:Body&gt; &lt;/v:Envelope&gt; </code></pre> <p>Testing in soapUI, the web service really wants to see:</p> <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:car="http://carefusion.com/"&gt; &lt;soapenv:Header/&gt; &lt;soapenv:Body&gt; &lt;car:getTest&gt; &lt;car:testint&gt;16874&lt;/car:testint&gt; &lt;/car:getTest&gt; &lt;/soapenv:Body&gt; &lt;/soapenv:Envelope&gt; </code></pre> <p>Which returns me my JSON. Im probably not using the ksoap library correctly. What can I do to my code to get the envelope formatted properly?</p> <p>FirstScreen.java</p> <pre><code> package carefusion.com.MyTest; import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.widget.ListView; import android.widget.TextView; public class FirstScreen extends Activity { /**Called when the activity is first created */ private static final String URL="http://10.220.13.202:8080/Respiratory/ResService.asmx"; private static final String SOAP_ACTION ="http://carefusion.com/getTest"; private static final String METHOD_NAME ="getTest"; private static final String NAMESPACE="http://www.carefusion.com/"; private static final String param="16875"; TextView tv; ListView lv; ArrayList&lt;AgentMetric&gt; agentMetricList = new ArrayList&lt;AgentMetric&gt;(); AgentMetric agentObj = new AgentMetric(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_first_screen); tv=(TextView)findViewById(R.id.TextView01); lv=(ListView)findViewById(R.id.ListView01); try { String response= new RetrieveJson().execute(URL, SOAP_ACTION, METHOD_NAME, NAMESPACE, param).get(); tv.setText(response); } catch(Exception e) { tv.setText(e.toString()); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.first_screen, menu); return true; } } </code></pre> <p>RetrieveJson.java</p> <pre><code> package carefusion.com.MyTest; import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.PropertyInfo; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE; import android.os.AsyncTask; import android.util.Log; public class RetrieveJson extends AsyncTask &lt;String, Void, String&gt; { @Override protected String doInBackground(String... URL) { String result=""; SoapObject Request=new SoapObject (URL[3].toString(),URL[2].toString()); PropertyInfo pi = new PropertyInfo(); pi.setName("testint"); pi.setValue(Integer.parseInt(URL[4].toString())); pi.setType(int.class); Request.addProperty(pi); SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); soapEnvelope.dotNet=true; soapEnvelope.setOutputSoapObject(Request); HttpTransportSE aht =new HttpTransportSE(URL[0].toString()); aht.debug=true; try { aht.call(URL[1].toString(), soapEnvelope); SoapObject response = (SoapObject)soapEnvelope.bodyIn; result = response.getProperty(0).toString(); } catch(Exception e) { e.printStackTrace(); } finally{ Log.i(getClass().getSimpleName(),"requestDump : "+aht.requestDump); Log.i(getClass().getSimpleName(),"responseDump : "+aht.responseDump); } return result; } @Override protected void onPostExecute(String result) { } } </code></pre>
 

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