Android:
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
public class Registration extends Activity {
private String METHOD_NAME ="insertRegistrationData";
private String NAMESPACE ="http://DefaultNamespace";
private String SOAP_ACTION ="RegistrationDataService";
private static final String URL="http://192.168.2.7:8080/AptbusServer/services/RegistrationData";
EditText pname,address,zip,birth;
TextView newpatient,exist;
RadioButton pnew,exis;
Button button;
private RadioGroup choice;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
pname=(EditText)findViewById(R.id.pname);
address=(EditText)findViewById(R.id.address);
zip=(EditText)findViewById(R.id.zip);
birth=(EditText)findViewById(R.id.birth);
choice=(RadioGroup)findViewById(R.id.ptype);
pnew=(RadioButton)findViewById(R.id.newpatient);
exis=(RadioButton)findViewById(R.id.exist);
button=(Button)findViewById(R.id.next);
button.setOnClickListener(new OnClickListener(){
String radio=null;
@Override
public void onClick(View v) {
Editable patientname=pname.getText();
String patname=patientname.toString();
Editable addr=address.getText();
String paddr=addr.toString();
Editable zipco=zip.getText();
String pzip=zipco.toString();
int pzipcode=Integer.parseInt(pzip);
Editable pbirth=birth.getText();
String pbirthdate=pbirth.toString();
if(pnew.isChecked())
{
radio=(String) pnew.getText();
}
if(exis.isChecked())
{
radio=(String) exis.getText();
}
Toast.makeText(getApplicationContext(),
patname+""+ paddr+""+ pzip+""+pbirthdate+""+radio, Toast.LENGTH_LONG).show();
try
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("s",patname);
request.addProperty("s1",paddr);
request.addProperty("zip",pzipcode);
request.addProperty("gender",radio);
request.addProperty("dat",pbirthdate);
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
soapEnvelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(
URL);
androidHttpTransport.call(SOAP_ACTION, soapEnvelope);
SoapPrimitive resultsRequestSOAP = (SoapPrimitive) soapEnvelope
.getResponse();
String result = resultsRequestSOAP.toString();
System.out.println("Result : " + result);
}
catch(Exception e)
{
System.out.println(e);
}
}
});
}
}
SOAP:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://DefaultNamespace" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://DefaultNamespace" xmlns:intf="http://DefaultNamespace" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:types>
<schema elementFormDefault="qualified" targetNamespace="http://DefaultNamespace" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="insertRegistrationData">
<complexType>
<sequence>
<element name="s" type="xsd:string"/>
<element name="s1" type="xsd:string"/>
<element name="zip" type="xsd:int"/>
<element name="gender" type="xsd:string"/>
<element name="dat" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="insertRegistrationDataResponse">
<complexType>
<sequence>
<element name="insertRegistrationDataReturn" type="xsd:int"/>
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
<wsdl:message name="insertRegistrationDataResponse">
<wsdl:part element="impl:insertRegistrationDataResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="insertRegistrationDataRequest">
<wsdl:part element="impl:insertRegistrationData" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="RegistrationData">
<wsdl:operation name="insertRegistrationData">
<wsdl:input message="impl:insertRegistrationDataRequest" name="insertRegistrationDataRequest">
</wsdl:input>
<wsdl:output message="impl:insertRegistrationDataResponse" name="insertRegistrationDataResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="RegistrationDataSoapBinding" type="impl:RegistrationData">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="insertRegistrationData">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="insertRegistrationDataRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="insertRegistrationDataResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="RegistrationDataService">
<wsdl:port binding="impl:RegistrationDataSoapBinding" name="RegistrationData">
<wsdlsoap:address location="http://localhost:8080/AptbusServer/services/RegistrationData"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
public class Registration extends Activity {
private String METHOD_NAME ="insertRegistrationData";
private String NAMESPACE ="http://DefaultNamespace";
private String SOAP_ACTION ="RegistrationDataService";
private static final String URL="http://192.168.2.7:8080/AptbusServer/services/RegistrationData";
EditText pname,address,zip,birth;
TextView newpatient,exist;
RadioButton pnew,exis;
Button button;
private RadioGroup choice;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
pname=(EditText)findViewById(R.id.pname);
address=(EditText)findViewById(R.id.address);
zip=(EditText)findViewById(R.id.zip);
birth=(EditText)findViewById(R.id.birth);
choice=(RadioGroup)findViewById(R.id.ptype);
pnew=(RadioButton)findViewById(R.id.newpatient);
exis=(RadioButton)findViewById(R.id.exist);
button=(Button)findViewById(R.id.next);
button.setOnClickListener(new OnClickListener(){
String radio=null;
@Override
public void onClick(View v) {
Editable patientname=pname.getText();
String patname=patientname.toString();
Editable addr=address.getText();
String paddr=addr.toString();
Editable zipco=zip.getText();
String pzip=zipco.toString();
int pzipcode=Integer.parseInt(pzip);
Editable pbirth=birth.getText();
String pbirthdate=pbirth.toString();
if(pnew.isChecked())
{
radio=(String) pnew.getText();
}
if(exis.isChecked())
{
radio=(String) exis.getText();
}
Toast.makeText(getApplicationContext(),
patname+""+ paddr+""+ pzip+""+pbirthdate+""+radio, Toast.LENGTH_LONG).show();
try
{
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("s",patname);
request.addProperty("s1",paddr);
request.addProperty("zip",pzipcode);
request.addProperty("gender",radio);
request.addProperty("dat",pbirthdate);
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
soapEnvelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(
URL);
androidHttpTransport.call(SOAP_ACTION, soapEnvelope);
SoapPrimitive resultsRequestSOAP = (SoapPrimitive) soapEnvelope
.getResponse();
String result = resultsRequestSOAP.toString();
System.out.println("Result : " + result);
}
catch(Exception e)
{
System.out.println(e);
}
}
});
}
}
SOAP:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://DefaultNamespace" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://DefaultNamespace" xmlns:intf="http://DefaultNamespace" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:types>
<schema elementFormDefault="qualified" targetNamespace="http://DefaultNamespace" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="insertRegistrationData">
<complexType>
<sequence>
<element name="s" type="xsd:string"/>
<element name="s1" type="xsd:string"/>
<element name="zip" type="xsd:int"/>
<element name="gender" type="xsd:string"/>
<element name="dat" type="xsd:string"/>
</sequence>
</complexType>
</element>
<element name="insertRegistrationDataResponse">
<complexType>
<sequence>
<element name="insertRegistrationDataReturn" type="xsd:int"/>
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
<wsdl:message name="insertRegistrationDataResponse">
<wsdl:part element="impl:insertRegistrationDataResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="insertRegistrationDataRequest">
<wsdl:part element="impl:insertRegistrationData" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="RegistrationData">
<wsdl:operation name="insertRegistrationData">
<wsdl:input message="impl:insertRegistrationDataRequest" name="insertRegistrationDataRequest">
</wsdl:input>
<wsdl:output message="impl:insertRegistrationDataResponse" name="insertRegistrationDataResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="RegistrationDataSoapBinding" type="impl:RegistrationData">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="insertRegistrationData">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="insertRegistrationDataRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="insertRegistrationDataResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="RegistrationDataService">
<wsdl:port binding="impl:RegistrationDataSoapBinding" name="RegistrationData">
<wsdlsoap:address location="http://localhost:8080/AptbusServer/services/RegistrationData"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
No comments:
Post a Comment