尝试使用Web服务发送Hashmap数组

时间:2015-07-08 13:05:21

标签: android web-services ksoap2

我尝试使用Android中的网络服务发送包含HashMap <String,Object>的数组,但是我有一个例外情况,说&#34;无法序列化HashMap&#34 ;,希望你能帮助我们。提前致谢! 以下是Web服务类:

public class AddUser {

String namespace = "the name space";
private String url = "the url";
String SOAP_ACTION;
SoapObject request;
SoapSerializationEnvelope envelope;
AndroidHttpTransport androidHttpTransport;

AddUser() {
}


//set envelope
protected void SetEnvelope() {

    try {

        envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);
        androidHttpTransport = new AndroidHttpTransport(url);
        androidHttpTransport.debug = true;


    } catch (Exception e) {
        System.out.println("Soap Exception---->>>" + e.toString());
    }
}


public String SetFicheUser(String MethodName,Object full_tab)
{

    try {
        SOAP_ACTION = "the soap action";

        //Adding values to request object
        request = new SoapObject(namespace, MethodName);
        PropertyInfo prop = new PropertyInfo();
        prop.setName("user");
        prop.setValue(full_tab);
        prop.setType(Object.class);
        request.addProperty(prop);
        SetEnvelope();


        try {

            androidHttpTransport.call(SOAP_ACTION, envelope);
            Object result = (Object)envelope.getResponse();
            return "";

        } catch (Exception e) {
            // TODO: handle exception
            return e.toString();
        }
    } catch (Exception e) {
        // TODO: handle exception
        return e.toString();
    }

}
}

0 个答案:

没有答案