Below code is for calling sample SOAP web-service in android.
String SOAP_ACTION = "your soap action url";
URL u = new URL("your server url");
URLConnection uc = u.openConnection();
HttpURLConnection connection = (HttpURLConnection) uc;
connection.setConnectTimeout(10000); // connection timedout value
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestProperty("SOAPAction", SOAP_ACTION);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-type", "text/xml; charset=utf-8");
String xmldata="copy and paste your request xml here..";
System.out.println("Request is : ");
System.out.println(xmldata);
OutputStream out = connection.getOutputStream();
Writer wout = new OutputStreamWriter(out);
wout.write(xmldata);
wout.flush();
out.flush();
BufferedReader rd = new BufferedReader(newInputStreamReader(connection.getInputStream()));
String result=rd.readLine(); // response...
String SOAP_ACTION = "your soap action url";
URL u = new URL("your server url");
URLConnection uc = u.openConnection();
HttpURLConnection connection = (HttpURLConnection) uc;
connection.setConnectTimeout(10000); // connection timedout value
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestProperty("SOAPAction", SOAP_ACTION);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-type", "text/xml; charset=utf-8");
String xmldata="copy and paste your request xml here..";
System.out.println("Request is : ");
System.out.println(xmldata);
OutputStream out = connection.getOutputStream();
Writer wout = new OutputStreamWriter(out);
wout.write(xmldata);
wout.flush();
out.flush();
BufferedReader rd = new BufferedReader(newInputStreamReader(connection.getInputStream()));
String result=rd.readLine(); // response...
This comment has been removed by the author.
ReplyDelete