vs2012 webservice建立

來源:互聯網
上載者:User

標籤:style   class   blog   http   com   width   

 第一步:開啟VS2012,建立空項目,注意選擇.NET Framework的版本.這裡我選擇的是.NET Framework 4

    

  建立好項目後,在項目中添加一個WebService項

開啟這個檔案,我們可以看到,代碼如下

[csharp] view plaincopyprint?
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using System.Web.Services;  
  6.   
  7. namespace CalculateService  
  8. {  
  9.     /// <summary>  
  10.     /// WebService1 的摘要說明  
  11.     /// </summary>  
  12.       
  13.   
  14.     [WebService(Namespace = "http://tempuri.org/")]  
  15.     [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]  
  16.     [System.ComponentModel.ToolboxItem(false)]  
  17.     // 若要允許使用 ASP.NET AJAX 從指令碼中調用此 Web 服務,請取消注釋以下行。   
  18.     // [System.Web.Script.Services.ScriptService]  
  19.     public class CalCulService : System.Web.Services.WebService  
  20.     {  
  21.   
  22.         [WebMethod]  
  23.         public string HelloWorld()  
  24.         {  
  25.             return "Hello World";  
  26.         }  
  27.     }  
  28. }  

接下來我們要將這個WebService打包發布

在項目上點擊右鍵,點擊菜單中的發布

 此時出現如下頁面

點擊下拉式功能表選擇建立設定檔

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.