asp.net将通过android消费的web服务

时间:2015-07-07 08:39:53

标签: asp.net web-services

我想为CRUD操作创建简单的android应用程序。我使用PHP和Mysql成功创建了这个应用程序。但现在我想使用asp.net。这是简单的webservice

using System;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;

[WebService(Namespace = "http://localhost/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]


public class Service : System.Web.Services.WebService
{
public Service () {

    //Uncomment the following line if using designed components 
    //InitializeComponent(); 
}

[WebMethod]
public string HelloWorld() {
    return "Hello World 124";
}

当我尝试运行此网址时,它会给我错误。

http://localhost:3541/WebSite3/Service.asmx/HelloWorld

无法识别对于' / HelloWorld'中意外结束的网址的请求格式。

我对.net不太了解。所以我错了什么?

我要做什么来运行这个???

提前致谢

1 个答案:

答案 0 :(得分:1)

这不是一个宁静的Web服务,所以你不能调用这样的方法。这是肥皂服务。

只需调用此网址,即可让您选择方法: http://localhost:3541/WebSite3/Service.asmx

然后在您的Android应用程序中,您可以使用ksoap2-android库来消费它。

在android中使用soap服务并不理想。我认为你应该看一下宁静的服务。

相关问题