简体   繁体   English

如何在Android应用程序中使用ASP.NET Web服务

[英]how to consume asp.net web service in android application

I have already created asp.net 3.0 web service. 我已经创建了asp.net 3.0 Web服务。 I tested it in sample application and it worked. 我在示例应用程序中对其进行了测试,并且可以正常工作。 It gives xml output. 它提供xml输出。 problrm id how to consume webservice in android application and sent parameters to the web server. problrm id如何在android应用程序中使用webservice并将参数发送到web服务器。

You can use Ksoap; 您可以使用Ksoap。

PropertyInfo pi = new PropertyInfo();
        pi.setName("Category");
        pi.setValue(C);
        pi.setType(C.getClass());
        Request.addProperty(pi);

Regarding the return type, if your web method returns a complex object (such as ours), you need to tell KSOAP how to handle the response. 关于返回类型,如果您的Web方法返回一个复杂的对象(例如我们的对象),则需要告诉KSOAP如何处理响应。 That is done with the following code: 这是通过以下代码完成的:

envelope.addMapping(NAMESPACE, "Category",new Category().getClass());


androidHttpTransport.call(SOAP_ACTION, envelope);
            SoapObject response = (SoapObject)envelope.getResponse();
            C.CategoryId =  Integer.parseInt(response.getProperty(0).toString());
            C.Name =  response.getProperty(1).toString();
            C.Description = (String) response.getProperty(2).toString();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM