Package com.factory.webserviceutils;
Import java.io.IOException;
Import java.util.ArrayList;
Import java.util.List;
Import Org.ksoap2.SoapEnvelope;
Import Org.ksoap2.SoapFault;
Import Org.ksoap2.serialization.SoapObject;
Import Org.ksoap2.serialization.SoapSerializationEnvelope;
Import Org.ksoap2.transport.HttpTransportSE;
Import org.xmlpull.v1.XmlPullParserException;
public class Webserviceutils {
Name space
public static final String service_namespace = "http://tempuri.org/";
public static final String Service_url = "http://192.168.1.156/ProduceManageSystemWebService/";
/*
* Return server data via WCF
* **/
public static list<string> GetUser () {
String methodName = "Getmanagement";
Httptransportse ht = new Httptransportse (Service_url);
try {
Ht.debug = true;
Soapserializationenvelope envelope = new Soapserializationenvelope (
SOAPENVELOPE.VER11);
Soapobject soapobject = new Soapobject (Service_namespace,
MethodName);
Envelope.bodyout = Soapobject;
Envelope.dotnet = true;
Ht.call (Service_namespace + methodName, envelope);
if (envelope.getresponse () = null) {
Soapobject result = (soapobject) Envelope.bodyin;
Soapobject detail = (soapobject) result.getproperty (methodName
+ "Result");
return Parseuser (detail);
/*string object = Result.getproperty (0). toString ();
System.out.println ("Helloservice::object" + Object); Return
Object
*/
}
} catch (SoapFault e) {
TODO auto-generated Catch block
E.printstacktrace ();
} catch (IOException e) {
TODO auto-generated Catch block
E.printstacktrace ();
} catch (Xmlpullparserexception e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
return null;
}
public static list<string> Parseuser (Soapobject detail) {
list<string> list = new arraylist<string> ();
for (int i = 0; i < Detail.getpropertycount (); i++) {
List.add (Detail.getproperty (i). ToString (). Split ("=") [1].split (";") [0]);
}
System.out.println ("list.size ()" + list.size ());
for (int i=0;i<list.size (); i++)
{
System.out.println ("List.get (i)" +list.get (i));
}
return list;
}
}