开发过程与在VS下开发webservice一致,在此仅仅对sharepoint2010 下webservice部署做简单说明。
1、生成.disco 文件
利用vs 命令行工具 敲入 disco http://localhost/<本地webservice路径>.asmx out:d:
2、修改.disco文件和.wsdl文件 头为:
<%@ Page Language="C#" Inherits="System.Web.UI.Page" %>
<%@ Assembly Name="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint.Utilities" %> <%@ Import Namespace="Microsoft.SharePoint" %>
<% Response.ContentType = "text/xml"; %>
3、修改.disco文件如下所示:
<discovery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/disco/">
<contractRef ref=<% SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(SPWeb.OriginalBaseUrl(Request) + "?wsdl"),Response.Output); %> docRef=<% SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(SPWeb.OriginalBaseUrl(Request)),Response.Output); %> xmlns="http://schemas.xmlsoap.org/disco/scl/" />
<soap address=<% SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(SPWeb.OriginalBaseUrl(Request)),Response.Output); %> xmlns:q1="http://schemas.microsoft.com/sharepoint/diagnostics/" binding="q1:SharePointDiagnosticsSoap" xmlns="http://schemas.xmlsoap.org/disco/soap/" />
<soap address=<% SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(SPWeb.OriginalBaseUrl(Request)),Response.Output); %> xmlns:q2="http://schemas.microsoft.com/sharepoint/diagnostics/" binding="q2:SharePointDiagnosticsSoap12" xmlns="http://schemas.xmlsoap.org/disco/soap/" />
</discovery>
4、修改.wsdl文件 soap节
<wsdl:service name="FileService">
<wsdl:port name="FileServiceSoap" binding="tns:FileServiceSoap">
<soap:address location=<% SPEncode.WriteHtmlEncodeWithQuote(Response,SPWeb.OriginalBaseUrl(Request), '"'); %> />
</wsdl:port>
<wsdl:port name="FileServiceSoap12" binding="tns:FileServiceSoap12">
<soap12:address location=<% SPEncode.WriteHtmlEncodeWithQuote(Response,SPWeb.OriginalBaseUrl(Request), '"'); %> />
</wsdl:port>
</wsdl:service>
5、修改文件名
如将FileService.wsdl 重命名为FileServicewsdl.wsdl
如将FileService.disco 重命名为FileServicewsdisco.disco
6、部署:将三个文件拷贝到...\14\ISAPI路径下。
对于webservice 的dll部署 有两种方案
BIN 部署与 GAC部署,BIN部署较简单,不用修改asmx文件,仅需要修改webconfig中的信任级别 <trust level="Full" originUrl="" />(full可能会不安全)
本文介绍在SharePoint2010环境下部署WebService的过程,包括生成和修改.disco及.wsdl文件的方法,以及部署的具体步骤。文章还提到了两种部署方案:BIN部署与GAC部署。
160

被折叠的 条评论
为什么被折叠?



