将参数从Android传递到Webservice

时间:2015-10-08 01:39:41

标签: java android web-services

我在将值从Android传递到Webservice时遇到问题。结果总是NULL,所以我认为它不能传递值。

这是我在android(WebserviceCall)中的代码:

 public String syncData(String MethodName) { try {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
         .permitAll().build();
        StrictMode.setThreadPolicy(policy);

        SOAP_ACTION = namespace + MethodName;
           request = new SoapObject(namespace, MethodName);     
           request.addProperty("_strInputWhereStatement", "NYX024;"); 
           request.addProperty("_strLicenseKey", "SSD_Key"); 
           SetEnvelope();
            try {              
                androidHttpTransport.call(SOAP_ACTION, envelope);    
                String strSites = envelope.getResponse().toString();
                return strSites;
            } 
            catch (Exception e) {
                return null;
            }
        } catch (Exception e) {
            return null;
        }
    }

以下是调用它的代码:

_WS = new WebserviceCall();

String _strGetData = _WS.syncData("Android_LoadStaff_Where");       
Toast.makeText(getApplicationContext(),"output: " + _strGetData, Toast.LENGTH_LONG).show();

以下是我正在使用的权限:

 <uses-permission android:name="android.permission.INTERNET" />

这是我的网络服务中的截图: webservice screenshot

当我尝试调试程序时,它在此处停止并返回null String strSites = envelope.getResponse().toString();

谢谢。

1 个答案:

答案 0 :(得分:0)

您是否也在服务器上调试过程? 为了得到答案,我尝试这样的事情

SoapObject soapObject = (SoapObject) envelope.bodyIn;
String response = soapObject.getProperty(0).toString();