在Android Studio中使用关联数组调用SOAP函数

时间:2018-07-10 05:58:08

标签: java php android soap

request = new SoapObject(NAMESPACE, METHODNAME);
            envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
            envelope.setOutputSoapObject(request);
            ht = new HttpTransportSE(this.urlWebservice,5000000);
            System.out.println("NAMESPACE " + NAMESPACE );
            System.out.println("METHODNAME " + METHODNAME);

            String [] str = new String[2];

            ArrayList<String> parameters  = new ArrayList<String>();
            parameters.add(WombConstants.configurationInfo.getappUsername());
            parameters.add(WombConstants.configurationInfo.getAppPassword());

            Map<String, String> map = new HashMap<String, String>();
            map.put("username", WombConstants.configurationInfo.getappUsername());
            map.put("password", WombConstants.configurationInfo.getAppPassword());

            System.out.println("Created HashMap "+map);
            System.out.println("Start Get Data");
            request.addProperty("password" , map);
            request.addProperty("password", WombConstants.configurationInfo.getAppPassword());

嗨,我在这里有一个代码列表,用于在Web服务中传递参数,但不幸的是,Web服务IAM调用了接受关联数组示例,它们是一个函数getAccount($ param),其中包含用户名和密码,例如$ param ['username' ] $ param ['password']问题是我不知道该怎么做,我尝试了hashmap和jsonObject仍然不起作用

这就是我的logcat所说的

  

07-10 13:55:54.543 5600-5613 / ph.gov.doh.womb D / dalvikvm:GC_FOR_ALLOC   已释放173K,6%已释放4380K / 4620K,已暂停11ms,总计11ms 07-10   13:55:54.543 5600-5613 / ph.gov.doh.womb W / System.err:   java.lang.RuntimeException:无法序列化:   {“用户名”:“ DFDGDFG_0_40”,“密码”:“ 123456”}           在org.ksoap2.serialization.SoapSerializationEnvelope.writeElement(SoapSerializationEnvelope.java:664)           在org.ksoap2.serialization.SoapSerializationEnvelope.writeProperty(SoapSerializationEnvelope.java:649)           在org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(SoapSerializationEnvelope.java:595)           在org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(SoapSerializationEnvelope.java:573)           在org.ksoap2.serialization.SoapSerializationEnvelope.writeElement(SoapSerializationEnvelope.java:658)           在org.ksoap2.serialization.SoapSerializationEnvelope.writeBody(SoapSerializationEnvelope.java:555)           在org.ksoap2.SoapEnvelope.write(SoapEnvelope.java:205)           在org.ksoap2.transport.Transport.createRequestData(Transport.java:134)           在org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:144)           在org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:116)           在org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:111)           在ph.gov.doh.womb.activities.synchronizations.tasks.UserSynchronization.doInBackground(UserSynchronization.java:161)           在ph.gov.doh.womb.activities.synchronizations.tasks.UserSynchronization.doInBackground(UserSynchronization.java:78)           在android.os.AsyncTask $ 2.call(AsyncTask.java:288)           在java.util.concurrent.FutureTask.run(FutureTask.java:237)           在android.os.AsyncTask $ SerialExecutor $ 1.run(AsyncTask.java:231)           在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)           在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:587)           在java.lang.Thread.run(Thread.java:841)07-10 13:55:54.543 5600-5613 / ph.gov.doh.womb I / System.out:错误:无法序列化:   {“用户名”:“ DFDGDFG_0_40”,“密码”:“ 123456”}

希望有人能提供帮助,谢谢大家!

0 个答案:

没有答案