havde noget gammelt kode liggende..
metoden i midlet
public String lookUp(String country, String number)
{
String result = null;
SoapObject rpc = new SoapObject("urn:airportservice",
"lookupPassport");
rpc.addProperty("in0", country);
rpc.addProperty("in1", number);
SoapSerializationEnvelope envelope = new
SoapSerializationEnvelope(
SoapEnvelope.VER10);
envelope.bodyOut = rpc;
//
http://localhost:8180/axis/services/urn:airportservice HttpTransport transport = new HttpTransport(getAppProperty("webservice"));
transport.debug = true;
try
{
transport.call("lookupPassport", envelope);
result = envelope.getResult().toString();
}
catch (XmlPullParserException ex)
{
ex.printStackTrace();
}
catch (IOException ex)
{
ex.printStackTrace();
}
return result;
}
---------------------
public class AirportServiceImpl implements AirportServiceIF {
public AirportServiceImpl()
{
}
/**
* lookup
*
* @param country String
* @param number String
* @return String
* @throws RemoteException
*/
public String lookupPassport(String country, String number) throws java.rmi.
RemoteException
{
String result = null;
Context init = null;
try
{
init = new InitialContext();
}
catch (NamingException ex3)
{
ex3.printStackTrace();
}
Context ctx = null;
try
{
ctx = (Context) init.lookup("java:comp/env");
}
catch (NamingException ex)
{
ex.printStackTrace();
}
DataSource ds = null;
try
{
ds = (DataSource) ctx.lookup("jdbc/AxisMySQL");
}
catch (NamingException ex1)
{
ex1.printStackTrace();
}
try
{
Connection con = ds.getConnection();
PreparedStatement stmt = con.prepareStatement(
"Select note FROM passport WHERE country = ? AND number = ?");
stmt.setString(1, country);
stmt.setString(2, number);
ResultSet rs = stmt.executeQuery();
while (rs.next())
{
result = rs.getString(1);
}
if (result == null)
{
result = "No information avalible";
}
}
catch (SQLException ex2)
{
ex2.printStackTrace();
}
return result;
}
}