How to pass Soap request for this kind of webservice
WEBSERVICE CODE: Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.ComponentModel ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. ' <System.Web.Script.Services.ScriptService()> _ <System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _ <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _ <ToolboxItem(False)> _ Public Class Service1 Inherits System.Web.Services.WebService Public Class InfoRequest Private NameField As String Private num1field As Integer Private num2field As Integer '''<remarks/> Public Property Name() As String Get Return Me.NameField End Get Set(ByVal value As String) Me.NameField = value End Set End Property '''<remarks/> Public Property num1() As Integer Get Return Me.num1field End Get Set(ByVal value As Integer) Me.num1field = value End Set End Property '''<remarks/> Public Property num2() As Integer Get Return Me.num2field End Get Set(ByVal value As Integer) Me.num2field = value End Set End Property End Class Public Class InfoResponse Private totalField As Integer '''<remarks/> Public Property total() As Integer Get Return Me.totalField End Get Set(ByVal value As Integer) Me.totalField = value End Set End Property End Class <WebMethod()> _ Public Function total(ByVal validationRequest As InfoRequest) As InfoResponse Dim resp As New InfoResponse Dim req = validationRequest Dim name As String = req.Name Dim num1 As Integer = req.num1 Dim num2 As Integer = req.num2 Dim tot As Integer = num1 + num2 resp.total = tot Return resp End Function End Class ANDROID CODE public class mas extends Activity { /** Called when the activity is first created. */ private static final String METHOD_NAME ="total"; private static final String NAMESPACE ="http://tempuri.org/"; private static final String SOAP_ACTION ="http://tempuri.org/ total"; private static final String URL ="http://10.0.2.2:1743/ Service1.asmx"; private TextView tv; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tv = (TextView) findViewById(R.id.tv); tv.setText(ws()); } private String ws() { String result = ""; try { SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); System.out.println("ohaissxh"); PropertyInfo quotesProperty = new PropertyInfo(); //quotesProperty.setName("Name"); //quotesProperty.setValue("chris"); //quotesProperty.setType(String.class); //request.addProperty(quotesProperty); request.addProperty("Name","Nas"); //request.addProperty("InfoRequest",request); request.addProperty("num1",6); // request.addProperty("InfoRequest",request); request.addProperty("num2",5); /* PropertyInfo name = new PropertyInfo(); name.setName("Name"); name.setValue("S"); request.addProperty(name);*/ /*PropertyInfo num1 = new PropertyInfo(); num1.setName("a"); num1.setValue(5); request.addProperty(num1); PropertyInfo num2 = new PropertyInfo(); num2.setName("b"); num2.setValue(9); request.addProperty(num2); */ SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(request); HttpTransportSE ht = new HttpTransportSE(URL); ht.call(SOAP_ACTION, envelope); System.out.println("dfdjsssf"); if(envelope.getResponse()!=null){ //SoapObject response = (SoapObject)envelope.bodyIn; Object response = envelope.getResponse(); result = response.toString(); } } catch (Exception e) { result = e.getMessage(); } return result; } } SOAP REQUEST: POST /Service1.asmx HTTP/1.1 Host: localhost Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://tempuri.org/total" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http:// schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <total xmlns="http://tempuri.org/"> <validationRequest> <Name>string</Name> <num1>int</num1> <num2>int</num2> </validationRequest> </total> </soap:Body> </soap:Envelope> SOAP RESPONCE: <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http:// schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <totalResponse xmlns="http://tempuri.org/"> <totalResult> <total>int</total> </totalResult> </totalResponse> </soap:Body> </soap:Envelope> -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

