android将数据发送到.net web服务

我正在尝试创建一个android应用程序,以将文本和照片发送到.net webservice。 我在我的web服务中有功能。 其中一个获得一个虚拟名称(我创建了这个来检查我是否可以建立连接),另一个是将一些数据插入到数据库中。 我想发布我的工作以获得帮助。

private final String NAMESPACE = "http://methodoor.com/";
//webservice is working, you can check it online
private final String URL = "http://servicing2.rotanet.com.tr/service.asmx";
private final String SOAP_ACTION = "http://methodoor.com/checkupservice/SendData";
private final String METHOD_NAME = "SendData";


       //Create request
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

    request.addProperty("containerId",1);
    .........
    .........           
    request.addProperty("sFileID","asd");
    request.addProperty("userId",1);

    //Create envelope
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true;
    //Set output SOAP object
    envelope.setOutputSoapObject(request);
    //Create HTTP call object
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try {
        //Invole web service
        androidHttpTransport.call(SOAP_ACTION, envelope);
        //Get the response
        SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
        //Assign it to fahren static variable
        fahren = response.toString();
    } catch (Exception e) {

    }

我的问题是,我不确定这是否是将数据传递给webservice的正确方法。 它不会崩溃或给出任何错误消息。 它只是没有插入数据库


在这里你去..确保检查您的服务中每个标记的拼写,方法名称和您的服务路径..

public SoapObject soap(String METHOD_NAME, String SOAP_ACTION, String NAMESPACE, String URL,String IP,String SERVICEPATH) throws IOException, XmlPullParserException 
 {
    abc.allowAllSSL();
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); //set up request
    //request.addProperty("iTopN", "5"); //variable name, value. I got the   variable      name, from the wsdl file!

    request.addProperty("UserId", login);
    request.addProperty("Password", password);


    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); // put all required data into a soap
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request); // prepare request
    envelope.bodyOut = request;
      Log.d("ENVELOPE",""+"Coming3");
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
    //androidHttpTransport.
    androidHttpTransport.call(SOAP_ACTION, envelope);

    Log.d("ENVELOPE",""+envelope.bodyIn);
    SoapObject result = (SoapObject) envelope.bodyIn; // get response
    Log.d("ENVELOPE",""+envelope.bodyIn);
    SoapObject responseBodyRaw,responseBody,tableRow;
    return result;
 }

这里是参数详情

private String NAMESPACE = "http://tempuri.org/";
private String SOAP_ACTION = "http://tempuri.org/UserProfile";
private String METHOD_NAME = "UserProfile";
private String URL="https://172.17.60.15/HostingService/PhoneForService.asmx";
//private String URL="https://172.19.2.250/testService/phone.asmx";
private String SERVICEPATH="/HostingService/PhoneForService.asmx";

我希望对你有所帮助

链接地址: http://www.djcxy.com/p/74517.html

上一篇: android send data to a .net webservice

下一篇: Best Way to Frequently Poll a Server from an Android App