tolomawa
11/05/11, 16:53:22
Muy buenas a todos,
Estoy desarrollando una aplicación que llama a unos servicios web. Utilizo un objeto soapobject para realizar la llamada y recibir los datos. Cuando hago la llamada a un servicio que no requiere autenticación todo funciona correctamente, el problema viene cuando ese serivicio web requiere una autenticación previa, ya que no sé como realizarla. ¿Alguien ha hecho algo parecido o tiene alguna idea al respecto?
Os envío el código simplificado del código que utilizo para llamar al servicio web:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String NAMESPACE = "http://tempuri.org/";
String METHOD_NAME = "HelloWorld";
String SOAP_ACTION = "http://tempuri.org/HelloWorld";
String URL = "http://00.000.0.000/HolaMundoServicio/Service1.asmx";
SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
/**PropertyInfo pi = new PropertyInfo();
pi.setName("Operand1");
pi.setValue(2);
pi.setType(int.class);
Request.addProperty(pi);
PropertyInfo pi2 = new PropertyInfo();
pi2.setName("Operand2");
pi2.setValue(5);
pi2.setType(int.class);
Request.addProperty(pi2); */
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(Request);
HttpTransportSE transporte = new HttpTransportSE(URL);
String result="";
try
{
transporte.call(SOAP_ACTION, envelope);
SoapPrimitive resultado = (SoapPrimitive) envelope.getResponse();
result= resultado.toString();
}
catch(Exception e)
{
result = "ERROR: " + e.getMessage();
}
TextView tv = new TextView(this);
tv.setText(result);
setContentView(tv);
}
Os agradecería vuestra ayuda
Muchas gracias un saludo
Estoy desarrollando una aplicación que llama a unos servicios web. Utilizo un objeto soapobject para realizar la llamada y recibir los datos. Cuando hago la llamada a un servicio que no requiere autenticación todo funciona correctamente, el problema viene cuando ese serivicio web requiere una autenticación previa, ya que no sé como realizarla. ¿Alguien ha hecho algo parecido o tiene alguna idea al respecto?
Os envío el código simplificado del código que utilizo para llamar al servicio web:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String NAMESPACE = "http://tempuri.org/";
String METHOD_NAME = "HelloWorld";
String SOAP_ACTION = "http://tempuri.org/HelloWorld";
String URL = "http://00.000.0.000/HolaMundoServicio/Service1.asmx";
SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
/**PropertyInfo pi = new PropertyInfo();
pi.setName("Operand1");
pi.setValue(2);
pi.setType(int.class);
Request.addProperty(pi);
PropertyInfo pi2 = new PropertyInfo();
pi2.setName("Operand2");
pi2.setValue(5);
pi2.setType(int.class);
Request.addProperty(pi2); */
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(Request);
HttpTransportSE transporte = new HttpTransportSE(URL);
String result="";
try
{
transporte.call(SOAP_ACTION, envelope);
SoapPrimitive resultado = (SoapPrimitive) envelope.getResponse();
result= resultado.toString();
}
catch(Exception e)
{
result = "ERROR: " + e.getMessage();
}
TextView tv = new TextView(this);
tv.setText(result);
setContentView(tv);
}
Os agradecería vuestra ayuda
Muchas gracias un saludo