Ksoap2在Android上使用Webservices时遇到麻烦

时间:2015-10-22 13:50:06

标签: android web-services android-intent android-activity ksoap2

我在.net中创建了一个webServices但是当我从我的Android应用程序中使用它时出现问题。我注意到web服务没有获取我从Android发送的参数。但是,我从.net应用程序中消耗它,它可以正常工作。

注意:使用其他网络服务(webservicex / globalweather .asmx),我的Android应用程序运行正常。

我在字符串URL变量中放了一些空格,因为我不能发布超过2个链接

public class cargaDatosWS {
    private static final String SOAP_ACTION = "http://www.esmerlinp.somee.com/getAccess";
    private static final String METHOD_NAME = "getAccess";
    private static final String NAMESPACE = "http://www.esmerlinp.somee.com";
    private static final String URL = "http ://www. esmerlinp.somee .com/Registro.asmx";

    public String getAcess(String Email,String Pwd){
        String res=null;
        SoapObject rpc;
        rpc = new SoapObject(NAMESPACE, METHOD_NAME);
        rpc.addProperty("email", Email);
        rpc.addProperty("password", Pwd);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.bodyOut = rpc;
        envelope.dotNet = true;
        envelope.encodingStyle = SoapSerializationEnvelope.XSD;
        HttpTransportSE androidHttpTransport= null;
        try {
            androidHttpTransport = new HttpTransportSE(URL);
            androidHttpTransport.debug = true;
            androidHttpTransport.call(SOAP_ACTION, envelope);
            res = envelope.getResponse().toString();

        }catch (Exception e){
            System.out.println(e.getMessage());
            res=e.getMessage();
        }

        return res;

    }

}

0 个答案:

没有答案