Android Web Service
14/01/2013
0
import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; //import org.ksoap2.serialization.SoapPrimitive; import org.ksoap2.transport.HttpTransportSE; public class Stage0 { private static final String SOAP_ACTION = "http://temuri.org/VerificaCartao"; private static final String METHOD_NAME = "VerificaCartao"; private static final String NAMESPACE = "http://temuri.org"; private static final String URL = "http://10.1.9.226/PDV/Service1.asmx"; public Cliente VerificaCartao(String cartao){ Cliente cliente = new Cliente(); SoapObject request = new SoapObject(NAMESPACE,METHOD_NAME); request.addProperty("cartao", cartao); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(request); try{ [b] HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);[/b] androidHttpTransport.call(SOAP_ACTION, envelope); SoapObject result = (SoapObject) envelope.getResponse(); cliente.setCd_cli(result.getProperty(0).toString()); cliente.setNm_cli(result.getProperty(1).toString()); cliente.setCd_atn(result.getProperty(2).toString()); cliente.setResp("True"); return cliente; }catch(Exception e) { //Log.e("pdv", e.getMessage()); e.getMessage(); cliente.setResp(e.getMessage()); return cliente ; } } }
O erro ficaria na linha do Http Transporte
OBS: Adicionei as permissões abaixo:
<uses-permission android:name="android.permission.INTERNET"></uses-permission> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
Thiago Garcez
Posts
01/02/2013
Andreza Oliveira
01/02/2013
Joel Rodrigues
03/02/2013
Danilo Gomes
Clique aqui para fazer login e interagir na Comunidade :)