M0286_Libro Curso
4: Web móvil en acción
“http://webservices.cloanto.com/currencyserver/”; // dirección del web service private static final String URL = “http://fx.cloanto.com/webservices/ CloantoCurrencyServer.asmx?WSDL”; Hemos importado la librería de kSOAP2 para poder usarlas: /** Called when the activity is first created. */ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout. main );
Button btnConsultar = (Button) findViewById(R.id. button1 ); btnConsultar.setOnClickListener(newView.OnClickListener()
{
public void onClick(View view) {
String sCadenaDevuelta = “no ha devuelto nada”; // definimos el objeto soap pasandole la SoapObject request = new request.addProperty(“licenseKey”, “4”); SoapSerializationEnvelope envelope = SoapObject result; envelope.dotNet = true; envelope.bodyOut = request; envelope.setOutputSoapObject(request); // realizamos la conexion HttpTransportSE httpTransport = new SoapEnvelope. VER11 ); httpTransport.debug = true; httpTransport.call( SOAP_ACTION , result = (SoapObject)envelope.bodyIn; sCadenaDevuelta = (result.toString()); try {
direccion y el metodo
SoapObject( NAMESPACE , METHOD_NAME );
new SoapSerializationEnvelope(
HttpTransportSE( URL );
envelope);
} catch (Exception exception) {
sCadenaDevuelta = (exception. } Toast. makeText (soapWebService.this,
toString());
245
Made with FlippingBook - Online catalogs