WebService操作
轉自:
http://blog.csdn.net/hi_kong/article/details/46356801
http://www.cnblogs.com/wayne-ivan/archive/2014/07/14/3842341.html
一、服務器端:
在VS2010中新建項目,首先選擇.net framework2.0,然后再選擇web服務應用程序。如圖所示:
然后在Service.cs文件中添加自己的方法即可。
二、C#winform調用webservice服務
新建C#winfrom工程,右鍵引用-》添加服務引用-》高級-》添加web引用,在URL后添加需要連接的url(運行上面web服務程序瀏覽器中就會出現連接的url),然后點擊后面的箭頭,再點添加引用即可。
假設引用的服務名為WebReference,類名稱為Service,
using System.Web.Services;
using System.Web.Services.Description;
在代碼中如下操作:
WebReference.Service1 helloWord = new WebReference.Service1();
helloWord .Url =WebUrl;//設置url
helloWord.helloWord();//調用webservice中的方法
結束。
WebService處理大數據量數據
在通過WebService處理大數據量數據時出現如下錯誤:
soap fault: 運行配置文件中指定的擴展時出現異常。 ---> 超過了最大請求長度。
解決方法:
因為上傳的文件大于系統默認配置的值,asp.net web service默認的請求長度是4M。
1、針對單個項目,只需修改Web.config就可以了:
修改配置可以在web.config中重新設置,如下:
<configuration>
<system.web>
<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
</system.web>
</configuration>