0

我开发了一个 android 应用程序并将一个类对象发送到一个 web 服务方法,我应该将一个数组作为响应,但它返回 anyType{}。

这是我的代码的一部分。

            Customer C = new Customer();
            C.setProperty(0,"30000001");

            PropertyInfo pi =new PropertyInfo();
            pi.setName("customer");        
            pi.setValue(C);            
            pi.setType(C.getClass());  
            request.addProperty(pi);   



            try{
            androidHttpTransport.call(SOAP_ACTION1, envelope);

            SoapObject response = (SoapObject) envelope.bodyIn;

                String[] denemeList;

                denemeList = new String[response.getPropertyCount()];

                for(int i=0; i<response.getPropertyCount(); i++)
                { 

                   denemeList[i] = response.getPropertyAsString(i).toString();
                   Log.d("This is the response",denemeList[i]);

                } 
                }catch (Exception e) {
                     TextView01.setText("EXCEPTION");
                     e.printStackTrace();
                }

我发现除了这个之外的其他一些代码,但它们都不起作用。有谁知道我该怎么办?

谢谢。

4

1 回答 1

0

注意:这是我的课程,我认为它会帮助您在您的项目中发布这个课程 2. 相应地替换变量 3. 调用方法:假设主类中的 getDistrictDetials ......这将在 CONSOL 窗口中打印输出

public class WebServiceCaller {

    private final String NAMESPACE = "http://tempuri.org/";
    private final String URL = "http://www.MYSERVICE/Service.asmx";
    private final String SOAP_ACTION = "http://tempuri.org/RASHTRWADI_State";
    private final String METHOD_NAME = "RASHTRWADI_State";



    public boolean getDistrictDetials() {
        boolean result = false;
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        PropertyInfo propInfo1 = new PropertyInfo();
        propInfo1.setName("State_Code");
        propInfo1.setValue(1);
        propInfo1.setType(int.class);
        request.addProperty(propInfo1);
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);
        envelope.dotNet = true; // put this only if the web service is .NET one
        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        try {
            androidHttpTransport.call(SOAP_ACTION, envelope);
            // SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
            Object response1 = envelope.getResponse();
            SoapObject response = (SoapObject) response1;

            Log.i("myApp", response1.toString());

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

}
于 2013-07-24T12:03:54.840 回答