{"id":105,"date":"2008-07-31T17:44:48","date_gmt":"2008-07-31T21:44:48","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=105"},"modified":"2008-08-19T09:54:05","modified_gmt":"2008-08-19T13:54:05","slug":"easy-net-web-service","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=105","title":{"rendered":"Easy .Net Web Service"},"content":{"rendered":"<p><strong>Create a hello world web service<\/strong><\/p>\n<li>Create a directory: c:\\HelloServices<\/li>\n<li>Create an asmx file: HelloService.asmx<\/li>\n<pre lang=\"csharp\">\r\n<%@ WebService Language=\"C#\" \r\n  Class=\"HelloService\"%>\r\n\r\nusing System;\r\nusing System.Web.Services;\r\nusing System.Xml.Serialization;\r\n\r\n[WebService(\r\n  Namespace=\"http:\/\/localhost\/HelloServices\/\")]\r\npublic class HelloService : WebService\r\n{\r\n    [WebMethod]\r\n    public string SayHello()\r\n    {\r\n        return \"Hello World!\";\r\n    }\r\n}<\/pre>\n<li>Create an IIS virtual directory: HelloServices and point to c:\\HelloServices<\/li>\n<li>Point browser to http:\/\/localhost\/HelloServices\/HelloService.asmx<\/li>\n<p><strong>Create an aspx web page to consume HelloService<\/strong><\/p>\n<li>Create a directory: c:\\HelloServiceWeb<\/li>\n<li>Create a subdirectory c:\\HelloServiceWeb\\bin<\/li>\n<li>Generate HelloService proxy\n<ul>\n<li>wsdl http:\/\/localhost\/HelloServices\/HelloService.asmx<\/li>\n<li>csc \/t:library HelloService.cs<\/li>\n<\/ul>\n<\/li>\n<li>Copy generated HelloService.dll to bin directory<\/li>\n<li>Create an aspx page: HelloServiceWeb.aspx<\/li>\n<pre lang=\"csharp\"><%@ Page Language=\"C#\" %>\r\n<script runat=server>\r\n  void runService_Click(\r\n    Object sender, EventArgs e)\r\n  {\r\n    HelloService hs = new HelloService();\r\n    Label1.Text = hs.SayHello();\r\n  }\r\n<\/script>\r\n<html>\r\n  <body>\r\n    <form id=\"Form1\" runat=server>\r\n      <asp:Label id=\"Label1\" \r\n        runat=\"server\">Label<\/asp:Label>\r\n      <br \/>\r\n      <asp:Button id=\"runService\" \r\n        onclick=\"runService_Click\"\r\n        runat=\"server\" \r\n        Text=\"Hello\"\/>\r\n    <\/form>\r\n  <\/body>\r\n<\/html><\/pre>\n<li>Create an IIS virtual directory: HelloServiceWeb and point to c:\\HelloServiceWeb<\/li>\n<li>Point browser to http:\/\/localhost\/HelloServiceWeb\/HelloServiceWeb.aspx<\/li>\n","protected":false},"excerpt":{"rendered":"<p>Create a hello world web service Create a directory: c:\\HelloServices Create an asmx file: HelloService.asmx using System; using System.Web.Services; using System.Xml.Serialization; [WebService( Namespace=&#8221;http:\/\/localhost\/HelloServices\/&#8221;)] public class HelloService : WebService { [WebMethod] public string SayHello() { return &#8220;Hello World!&#8221;; } } Create &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=105\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[5],"tags":[],"class_list":["post-105","post","type-post","status-publish","format-standard","hentry","category-c"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-1H","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=105"}],"version-history":[{"count":0,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/105\/revisions"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}