如何使用kso​​ap2从android发送过滤器参数到navision web服务?

时间:2014-08-22 07:13:37

标签: android ksoap2 navision

如何使用kso​​ap2从android传递过导航网络服务的过滤器?我收到所有数据并且传递的过滤器无法正常工作。通过过滤器的正确方法是什么?

我试过

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE, OPERATION_NAME);

    envelope.dotNet = true;
    request.addProperty("City_Code","2");

我想获得City_Code为2的城镇,但是上面的代码会返回所有城镇。

我也试过

    HashMap<String, String> filter = new HashMap<String, String>();

    filter.put("Field", "City_Code");
    filter.put("Criteria", "2");
    request.addProperty("Town_List_Filter",filter);

    envelope.setOutputSoapObject(request)

使用此代码我没有得到任何回复。

1 个答案:

答案 0 :(得分:0)

试试这个。

您只需创建一个简单的数组,然后只需将其作为参数传递给 request.addproperty 方法。< / p>

         try {

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                    SoapEnvelope.VER11);
            envelope.implicitTypes = true;
            envelope.setAddAdornments(false);
            envelope.dotNet = true;
            envelope.encodingStyle = SoapSerializationEnvelope.XSD;
            SoapObject request = new SoapObject("", METHOD_NAME);    //Your method name 

            for (int i = 0; i < key.length; i++) {
                request.addProperty(key[i], value[i]);       //your key and values as an array
            }

            envelope.setOutputSoapObject(request);

            HttpTransportSE ht = new HttpTransportSE(URL);      //Your URL
            ht.debug = true;
            ht.call(SOAP_ACTION, envelope);       //Your Soap_Action 
            s = ht.responseDump;

            Log.d(TAG, "HTTP REQUEST:\n" + ht.requestDump);
            Log.d(TAG, "HTTP RESPONSE:\n" + s);

        } catch (Exception e) {
            e.printStackTrace();
        }

        return s;

希望它适合你。