import java.io.IOException;
import java.io.InputStream;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransport;
import org.xml.sax.InputSource;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.XYEdges;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.CheckboxField;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;
import net.rim.device.api.ui.decor.Border;
import net.rim.device.api.ui.decor.BorderFactory;
/**
* A class extending the MainScreen class, which provides default standard
* behavior for BlackBerry GUI applications.
*/
public final class MyScreen extends MainScreen
{
LabelField lbl_UserName,lbl_Password;
EditField edf_UserName,edf_Password;
CheckboxField chk_Remember;
ButtonField btn_Login;
VerticalFieldManager vm_MainFieldManager,vm_btnFieldManager;
int deviceWidth = Display.getWidth();
int deviceHeight = Display.getHeight();
allmethods all_layout=new allmethods();
public MyScreen()
{
setTitle("Login Screen");
vm_MainFieldManager=all_layout.getCustomVerticalManager2(deviceWidth, deviceHeight);
lbl_UserName = new LabelField("UserName :");
lbl_Password = new LabelField("Password :");
edf_UserName = new EditField();
edf_Password = new EditField();
chk_Remember = new CheckboxField("Remember me", false);
XYEdges xy=new XYEdges(12, 12, 12, 12);
Bitmap bit_Rount = Bitmap.getBitmapResource("rounded.png");
Border brd_Rount = BorderFactory.createBitmapBorder(xy, bit_Rount);
edf_UserName.setBorder(brd_Rount);
edf_Password.setBorder(brd_Rount);
vm_btnFieldManager = new VerticalFieldManager(Field.FIELD_RIGHT);
btn_Login = new ButtonField("Login");
btn_Login.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
// TODO Auto-generated method stub
loginPArse();
}
});
vm_btnFieldManager.add(btn_Login);
vm_MainFieldManager.add(lbl_UserName);
vm_MainFieldManager.add(edf_UserName);
vm_MainFieldManager.add(lbl_Password);
vm_MainFieldManager.add(edf_Password);
vm_MainFieldManager.add(chk_Remember);
vm_MainFieldManager.add(vm_btnFieldManager);
add(vm_MainFieldManager);
}
public void loginPArse()
{
System.out.println("Entrando a Services2");
String serviceUrl = "http://45.pmam.com/PMAMSS-Webservices/MobileService.asmx;interface=wifi";
String serviceNameSpace = "http://tempuri.org/";
String soapAction = "http://tempuri.org/LoginCheck";
String methodName = "LoginCheck";
SoapObject rpc = new SoapObject(serviceNameSpace, methodName);
rpc.addProperty ("UserName".trim(), edf_UserName.getText().trim());
rpc.addProperty ("Password".trim(), edf_Password.getText().trim());
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = rpc;
envelope.dotNet = true;//<strong>IF you are accessing .net based web service this should be true</strong>
envelope.encodingStyle = SoapSerializationEnvelope.XSD;
HttpTransport ht = new HttpTransport(serviceUrl);
ht.debug = true;
ht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
String result = null;
try
{
ht.call(soapAction, envelope);
//Dialog.inform(ht.responseDump);
//result = (envelope.getResponse()).toString();
result = (envelope.getResult()).toString();
SoapObject body = (SoapObject)envelope.bodyIn;
result = (String)body.getProperty("LoginCheckResult").toString();
Dialog.inform(result);
}
catch(org.xmlpull.v1.XmlPullParserException ex2)
{
Dialog.inform(ex2.getMessage());
}
catch(Exception ex)
{
Dialog.inform(ex.getMessage());
}
}
public void xml()throws IOException
{
}
}
No comments:
Post a Comment