I have a .Net Web Service running on IIS v6 on a Windows XP 64 laptop
connected to a wifi network at home called intellinet. Now the .Net WS is
running on the laptop with the ip address 192.168.2.103. The laptop is also
running an SQL Server 2008 sp3 by means where the WS can communicate with
it.
SQL Server 2008 sp3 is can be run with sa account login.
The following is the asmx file on the WS
=======================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Collections;
namespace TaxiMoveWebService
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "bata.co.za/", Name = "TaxiMoveWebservice",
Description = "Webservice for TaxiMove Application")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET
AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public string CheckMarhsalLogin(string LoginUsername, string
LoginPassword)
{
string output = "";
try
{
using (SqlConnection myConnection = new
SqlConnection(@"Data Source= JAKES-LAPTOP;Initial Catalog=TaxiMoveV2;User
ID=sa;Password=garrison"))
{
myConnection.Open();
using (SqlCommand myCommand = new SqlCommand())
{
myCommand.Connection = myConnection;
myCommand.CommandText = "SELECT * FROM
Employee WHERE LoginUsername = @Username AND LoginPassword = @Password";
myCommand.Parameters.Add("@UserName",
SqlDbType.NVarChar, 50).Value = LoginUsername;
myCommand.Parameters.Add("@Password",
SqlDbType.NVarChar, 50).Value = LoginPassword;
if(int.Parse(myCommand.ExecuteScalar().ToString()) == 1)
{
output = "success";
}
else
{
output = "bad username or password";
}
}
}
}
catch (Exception ex)
{
output = "an error occurred." + ex.ToString();
}
return output;
}//end of webmethod
}
}
and my java code is this on a class called DataAccessLayer.java
=====================================================
package com.jstsolutions.android.taximove;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import android.app.AlertDialog;
public class DataAccessLayer {
public final String WSDL_TARGET_NAMESPACE = "bata.co.za/";
public final String SOAP_ADDRESS =
"http://192.168.2.103/TaxiMoveWebService/TaxiMove.asmx";
public final String spa_HalloWorld = "bata.co.za/HelloWorld";
public final String opn_HelloWorldResult = "HelloWorldResult";
public final String spa_ReturnMarshal = "bata.co.za/CheckMarhsalLogin";
public final String opn_CheckMarhsalLoginResult = "CheckMarhsalLoginResult";
public String ReturnHalloWorld()
{
SoapObject request = new
SoapObject(WSDL_TARGET_NAMESPACE,opn_HelloWorldResult);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
Object response=null;
try
{
httpTransport.call(spa_HalloWorld, envelope);
response = envelope.getResponse();
}
catch (Exception exception)
{
response=exception.toString();
}
return response.toString();
}
public String ValidMarshalLogin(String EnteredUsername, String
EnteredPassword)
{
SoapObject request = new
SoapObject(WSDL_TARGET_NAMESPACE,opn_CheckMarhsalLoginResult);
//SoapObject parameters = new
SoapObject(WSDL_TARGET_NAMESPACE,opn_CheckMarhsalLoginResult);
request.addProperty("LoginUsername",EnteredUsername.toString());
request.addProperty("LoginPassword",EnteredPassword.toString());
//request.addProperty(opn_CheckMarhsalLoginResult,parameters);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
//envelope.bodyOut = request;
//envelope.encodingStyle = SoapEnvelope.XSD;
//envelope.setAddAdornments(false);
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
httpTransport.setXmlVersionTag("<?xml version=\"1.0\"
encoding=\"UTF-8\"?>");
httpTransport.debug = true;
//Object response=null;
String response;
//int responseInt = (Integer)envelope.getResponse();;
try
{
//SoapObject responseChild = (SoapObject) response.getProperty(0);
//String hhh = responseChild.toString();
httpTransport.call(spa_ReturnMarshal, envelope);
//response = envelope.getResponse().toString();
SoapPrimitive responsesData = (SoapPrimitive) envelope.getResponse();
response = responsesData.toString();
}
catch (Exception exception)
{
response= "ERROR LOGIN EXCEPTION"; //exception.toString();
}
return response;
}
}
I have run the Web Service on debug in Visual Studio 2010 and as I type a
username and password in and then press the login button, I can see that
the web method gets executed. Is making a successful connection to my
database. One thing I noticed, and is now becoming a pain in the butt is
the fact that the parameters are null.
The HalloWorld webmethod is the only one working, when I launch the android
app on my HTC Flyer it displays the hallo world string in a AlertDialoge.
Internet Options setting is also set correct under Access data sources over
domains AND Navigate window and frames across different domains.
Can anyone please post me a solution here.
I'm despite :(
I need this knowledge to build an android app for my final year project of
software development at NMMU.
Please no none tested solutions, I have wasted already days going over
so-called solutions found on Google....
I will even mention your nickname or full name if you like, in our
innovation day of our project.
Come on :) I'll give you credit
--
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