Pass An Array To A Soap Web Service For Inserting Into Remote Database
Solution 1:
This is the sample code for reading SOAP web service, Hope this will help you,
privatestaticStringSOAP_ACTION="http://tempuri.org/HelloWorld";
privatestaticStringNAMESPACE="http://tempuri.org/";
privatestaticStringMETHOD_NAME="HelloWorld";
privatestaticStringURL="http://bimbim.in/Sample/TestService.asmx?WSDL";
/** Called when the activity is first created. */@OverridepublicvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Initialize soap request + add parametersSoapObjectrequest=newSoapObject(NAMESPACE, METHOD_NAME);
//Use this to add parameters
request.addProperty("Parameter","Value");
//Declare the version of the SOAP requestSoapSerializationEnvelopeenvelope=newSoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
//Needed to make the internet callHttpTransportSEandroidHttpTransport=newHttpTransportSE(URL);
try {
//this is the actual part that will call the webservice
androidHttpTransport.call(SOAP_ACTION, envelope);
} catch (Exception e) {
e.printStackTrace();
}
// Get the SoapResult from the envelope body.SoapObjectresult= (SoapObject)envelope.bodyIn;
if(result != null){
TextViewt= (TextView)this.findViewById(R.id.resultbox);
//Get the first property and change the label text
t.setText("SOAP response:\n\n" + result.getProperty(0).toString());
}
}
Also look at
Android Lists IV: Accessing and Consuming a SOAP Web Service I
The Droid Chronicles – Web Services: Using kSOAP2 to Pass Complex Objects
EDIT:
It is a known issue with the KSOAP2 for Android library, which at the moment simply does not support arrays. The issue description is here:
http://code.google.com/p/ksoap2-android/issues/detail?id=19
A third-party patch, solution and an example can be found here:
http://people.unica.it/bart/ksoap2-patch/
Look on these link, You can find your answer on that.
Thanks.
Solution 2:
Serialize to JSON or XML, send that JSON or XML to the server, decode that JSON or XML on the server. Not sure about the exact methods you would use in your case.
Post a Comment for "Pass An Array To A Soap Web Service For Inserting Into Remote Database"