Note that there are some explanatory texts on larger screens.

plurals
  1. POPass ArrayList data into SOAP web service in android
    primarykey
    data
    text
    <p>Hello, I need to pass Array-list data into soap web service. So far, I have the following code.</p> <pre><code> public class ResultActivity extends Activity { public final String NAMESPACE = ""; public final String URL = ""; public final String SOAP_ACTION_1 = ""; public final String METHOD_NAME_1 = ""; ProgressDialog mProgressDialog; SoapObject mSoapObjectCompanyDetailResponse; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.result); System.out.println("Size In resxusr " + OnLineApplication.mParserResults.size()); for (int i = 0; i &lt; OnLineApplication.mParserResults.size(); i++) { System.out.println("ID " + OnLineApplication.mParserResults.get(i).getCompanyId()); System.out.println("Q " + OnLineApplication.mParserResults.get(i).getQuestion()); System.out.println("A " + OnLineApplication.mParserResults.get(i).getAnswer()); } new insertResult().execute(); } public class insertResult extends AsyncTask&lt;Void, Void, Void&gt; { @Override protected void onPreExecute() { // TODO Auto-generated method stub super.onPreExecute(); mProgressDialog = ProgressDialog.show(ResultActivity.this, "Wait", "Fetching"); } @Override protected Void doInBackground(Void... params) { SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME_1); // request.addProperty("dt",""); for (int i = 0; i &lt; OnLineApplication.mParserResults.size(); i++) { request.addProperty("CompanyID", 30); request.addProperty("Question", OnLineApplication.mParserResults.get(i).getQuestion()); request.addProperty("Answer", OnLineApplication.mParserResults.get(i).getAnswer()); } SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(request); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); try { androidHttpTransport.call(SOAP_ACTION_1, envelope); mSoapObjectCompanyDetailResponse = (SoapObject) envelope.bodyIn; Object re = null; re = envelope.getResponse(); Log.i("myApp", mSoapObjectCompanyDetailResponse.toString()); System.out.println("re " + mSoapObjectCompanyDetailResponse.toString()); // mStringCompanyID=re.toString(); } catch (Exception e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Void result) { // TODO Auto-generated method stub super.onPostExecute(result); if (mProgressDialog != null) { mProgressDialog.dismiss(); } } } } </code></pre> <p><strong>My XML WSDL service is as following.</strong></p> <pre><code> &lt;wsdl:types&gt; &lt;s:element name="insertResultUser"&gt; &lt;s:complexType&gt; &lt;s:sequence&gt; &lt;s:element minOccurs="0" maxOccurs="1" name="dt"&gt; &lt;s:complexType&gt; &lt;s:sequence&gt; &lt;s:any minOccurs="0" maxOccurs="unbounded" namespace="http://www.w3.org/2001/XMLSchema" processContents="lax"/&gt; &lt;s:any minOccurs="1" namespace="urn:schemas-microsoft-com:xml-diffgram-v1" processContents="lax"/&gt; &lt;/s:sequence&gt; &lt;/s:complexType&gt; &lt;/s:element&gt; &lt;/s:sequence&gt; &lt;/s:complexType&gt; &lt;/s:element&gt; &lt;s:element name="insertResultUserResponse"&gt; &lt;s:complexType&gt; &lt;s:sequence&gt; &lt;s:element minOccurs="0" maxOccurs="1" name="insertResultUserResult" type="s:string"/&gt; &lt;/s:sequence&gt; &lt;/s:complexType&gt; &lt;/s:element&gt; &lt;/s:schema&gt; &lt;/wsdl:types&gt; &lt;wsdl:portType&gt; &lt;wsdl:operation name="insertResultUser"&gt; &lt;wsdl:input message="tns:insertResultUserSoapIn"/&gt; &lt;wsdl:output message="tns:insertResultUserSoapOut"/&gt; &lt;/wsdl:operation&gt; &lt;/wsdl:portType&gt; </code></pre> <p><strong>The following structure of data is what I need to pass to the web service as described above.</strong></p> <pre><code>dt=anyType{DocumentElement=anyType{questions=anyType{CompanyID=1; Question=what is android?; Answer=OS; }; questions=anyType{CompanyID=1; Question=what is android?; Answer=OS; }; questions=anyType{CompanyID=1; Question=what is android?; Answer=OS; }; questions=anyType{CompanyID=1; Question=what is android?; Answer=OS; }; questions=anyType{CompanyID=1; Question=what is android?; Answer=OS; }; }; }; }; } </code></pre> <p>When I run the above code I am unable to post the Arraylist data to the server. In my onCreate method, I am able to print my Arraylist values. How can I solve this? </p>
    singulars
    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.
 

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