Hi I am new to android development. I have created a soap webservices and created a android application to get username and password as shown below:
Firstscreen.xml:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:stretchColumns="1" >
<TableRow
android:gravity="center"
android:paddingTop="45dp" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/hint"
android:text="@string/username" />
<!-- Text Editor -->
<EditText
android:id="@+id/enterusername"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="text" />
</TableRow>
<TableRow>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/hint"
android:text="@string/password" />
<!-- Text Editor -->
<EditText
android:id="@+id/entertextpassword"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textPassword" />
</TableRow>
<TableRow>
<Button
android:id="@+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_span="2"
android:clickable="true"
android:gravity="center"
android:text="@string/login" >
</Button>
</TableRow>
</TableLayout>
So, I will get two fields(username and password) from user. I want to post or send the data to a SOAP webservice which has
url: "http://localhost:8100/ws/hello?wsdl"
and Qname: "http://Common.Hospital/", "HelloWorldImplService".
Can anybody help me to get resolved my problem. Thanks in advance.
And here is a sample code to send request to webservice :
public class SoapRequest {
private static final String SOAP_ACTION = "xxx";
private static final String METHOD_NAME = "xxx";
private static final String NAMESPACE = "xxx";
private static final String URL = "url of the webservice";
public static SoapObject soap() throws IOException, XmlPullParserException {
SoapObject request = new SoapObject (NAMESPACE, METHOD_NAME);
/* Here you can add properties to your requests */
PropertyInfo pi1 = new PropertyInfo();
pi1.name = "xxx";
pi1.type = String.class;
request.addProperty(pi1, "xxx");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapObject soapResult = (SoapObject) envelope.bodyIn;
return soapResult;
}
Check out this library https://code.google.com/p/ksoap2-android/ . It is a light-weight SOAP client implementation. However, I would recommend you to use Rest instead of SOAP.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.