来自C#Web服务的android raed对象列表上的Ksoap

时间:2018-10-19 09:30:32

标签: java android ksoap

我有一个C#Web服务(肥皂),我想将其与使用kso​​ap的android客户端一起使用。

我的Web服务给出的答案如下:

<ArrayOfPointage xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/">
<Pointage>
<Datepointage>2018-10-18T07:53:04</Datepointage>
<Status>Check In</Status>
<Modeverification>Empreint Degital</Modeverification>
<Machineid>1</Machineid>
<Userid>2</Userid>
</Pointage>
<Pointage>
<Datepointage>2018-10-18T08:34:43</Datepointage>
<Status>7</Status>
<Modeverification>Empreint Degital</Modeverification>
<Machineid>1</Machineid>
<Userid>2</Userid>
</Pointage>
<Pointage>
<Datepointage>2018-10-18T12:34:01</Datepointage>
<Status>Check In</Status>
<Modeverification>Empreint Degital</Modeverification>
<Machineid>1</Machineid>
<Userid>2</Userid>
</Pointage>
<Pointage>
<Datepointage>2018-10-18T13:40:59</Datepointage>
<Status>Check In</Status>
<Modeverification>Empreint Degital</Modeverification>
<Machineid>1</Machineid>
<Userid>2</Userid>
</Pointage>
<Pointage>
<Datepointage>2018-10-18T18:34:55</Datepointage>
<Status>Check Out</Status>
<Modeverification>Empreint Degital</Modeverification>
<Machineid>1</Machineid>
<Userid>2</Userid>
</Pointage>
</ArrayOfPointage>

我如何使用Java在Android应用程序中读取此对象列表。 我尝试了此Java代码,但确实有用:

public static Void GetPointage(int userid,int year,int month,int day) throws IOException, XmlPullParserException {
        SoapObject request = new SoapObject("http://tempuri.org/", "GetPointages");
        request.addProperty("userid", userid);
        request.addProperty("year", year);
        request.addProperty("month", month);
        request.addProperty("day", day);
        SoapSerializationEnvelope envlope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envlope.dotNet = true;
        envlope.setOutputSoapObject(request);
        HttpTransportSE transport = new HttpTransportSE("http://192.168.1.83:82/WSPointage.asmx");
        transport.call("http://tempuri.org/GetPointages", envlope);
        SoapObject result = (SoapObject) envlope.getResponse();
        SoapObject result2 = (SoapObject) envlope.bodyIn;
        int count=result2.getPropertyCount();
        for(int i=0; i<count; i++)
        {
            SoapObject result3 =(SoapObject) result2.getProperty(i);
            String date= result3.getProperty("Datepointage").toString();
        }
        return  null;
    }

0 个答案:

没有答案