开发者

Creating a web service in C#

I have sybase stored procedures that I have written which we use in our c# application and all is working well. Now I am trying to use an IPAD and be able to call those stored procedures. From what I understand I will need to build a webservice and expose those stored procedures. I have become very familiar with IPHONE ( developed an app). I learned how to call a web service from an IPHONE by posting some questions here and getting some tutorials.

I need to know how to build a web servic开发者_StackOverflowe in c# or if mac has an equivalent then so be it. Are there documentation on how to build a web service around a stored procedure or even a sql? I gladly read any books or documentations but I can't find any that is worth while.

Thanks Saro


I would definately recommend looking at WCF based web services rather than the old asmx web services. If you use WCF creating a service communicating in json is as easy as doing proper attribute decoration. What you need to look for is the WebHttpBinding and a

     [WebGet(ResponseFormat = WebMessageFormat.Json)]

decorator on your methods. You can also use uri matching to get parameters etc.

    [OperationContract]
    [WebGet(UriTemplate = "/lookup/{username}", ResponseFormat = WebMessageFormat.Json)]
    Model.UserIdentifierResponse LookupUser(string username);

(Here the {username} is matched with the input parameter.)

http://msdn.microsoft.com/en-us/library/bb412178.aspx


Even if it is pretty old (but still valid), HERE is a short introduction into .net/C#-WebServices. Basically WebServices are easy in .net, becasue the framework does most of the work for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜