Custom Web Servic In MOSS 2007

时间:2023-03-09 08:45:23
Custom Web Servic In MOSS 2007

Tools: Visual Studio 2008,Visual Studio 2008 Command Prompt, Sharepoint Server 2007

  1. Generate .disco and .wsdl files through Visual Studio 2008 Command Prompt in Visual Studio Tools

Custom Web Servic In MOSS 2007

Run command:

Disco http://sp2007:14908/_vti_bin/PSWebService.asmx

<%@ WebService Language="C#" Class="NameSpace.PSWebService, NameSpace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0c8763d1ab14ce97"  %>

Error occurred as below.

Custom Web Servic In MOSS 2007

Solution: Please move PSWebService.asmx into layouts folder and try it again. It works fine. Correct screen is as below.

Custom Web Servic In MOSS 2007

Two files(pswebservice.disco and pswebservice.wsdl) are stored in the path ‘C:\Temp\aa’

Note: You have to rename these two files(pswebservicedisco.aspx and pswebservicewsdl.aspx). You have to move these three files into ISAPI folder. The structure is below.

Custom Web Servic In MOSS 2007

 

  1. These two files are not able to use and you have to change parts of content.

For pswebservicedisco.aspx, substitute below original for current code

Original Code 1:

<?xml version="1.0" encoding="utf-8"?>

Current Code 1:

<%@ Page Language="C#"   Inherits="System.Web.UI.Page"    %> <%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0,   Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint.Utilities"   %> <%@ Import Namespace="Microsoft.SharePoint"   %>

<% Response.ContentType = "text/xml";   %>

Original Code 2:

<contractRef ref="http://sp2007:14908/_layouts/pswebservice.asmx?wsdl" docRef="http://sp2007:14908/_layouts/pswebservice.asmx" xmlns="http://schemas.xmlsoap.org/disco/scl/" />

<soap address="http://sp2007:14908/_layouts/pswebservice.asmx" xmlns:q1="http://tempuri.org/" binding="q1:PSWebServiceSoap" xmlns="http://schemas.xmlsoap.org/disco/soap/" />

<soap address="http://sp2007:14908/_layouts/pswebservice.asmx" xmlns:q2="http://tempuri.org/" binding="q2:PSWebServiceSoap12" xmlns="http://schemas.xmlsoap.org/disco/soap/" />

Current Code 2:

<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/soap/2002/1/alerts/"   binding="q1:   PSWebServiceSoap" 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/soap/2002/1/alerts/"   binding="q2:PSWebServiceSoap12"   xmlns="http://schemas.xmlsoap.org/disco/soap/"   />

Note: You are able to copy current code from alertsdisco file below.

Custom Web Servic In MOSS 2007

For pswebservicewsdl.aspx, substitute below original for current code

Original Code 1:

<?xml version="1.0" encoding="utf-8"?>

Current Code 1:

<%@ Page Language="C#"   Inherits="System.Web.UI.Page"    %> <%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0,   Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint.Utilities"   %> <%@ Import Namespace="Microsoft.SharePoint"   %>

<% Response.ContentType = "text/xml"; %>

Original Code 2:

<soap:address location="http://sp2007:14908/_layouts/pswebservice.asmx" />

Current Code 2:

<soap:address location=<%   SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(SPWeb.OriginalBaseUrl(Request)),Response.Output);   %> />

Original Code 3:

<soap12:address location="http://sp2007:14908/_layouts/pswebservice.asmx" />

Current Code 3:

<soap12:address location=<%   SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(SPWeb.OriginalBaseUrl(Request)),Response.Output);   %> />

Note: You are able to copy current code from alertswsdl file below.

Then you are able to deploy pswebservice web service, once done. You have to modify  spdisco.aspx file that is located in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\12\ISAPI and add the following code, specifying the .asmx file for your Web service.

<contractRef   ref=<% SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(spWeb.Url + "/_vti_bin/AWebService/PSWebService.asmx?wsdl"),   Response.Output); %>

docRef=<%   SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(spWeb.Url + "/_vti_bin/AWebService/PSWebService.asmx"),   Response.Output); %>

xmlns="   http://schemas.xmlsoap.org/disco/scl/ " />

<discoveryRef   ref=<% SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(spWeb.Url + "/_vti_bin/AWebService/PSWebService.asmx?disco"),Response.Output);   %>

xmlns="http://schemas.xmlsoap.org/disco/"   />

Your web service is able to be used till now.