
Generating and Modifying Discovery and WSDL Files
To provide discovery and description for your custom Web service, you must create a .disco file and a .wsdl file. Because Windows SharePoint Services virtualizes URLs, you cannot directly use the .disco and .wsdl files generated by ASP.NET. Instead, you must create the .disco and .wsdl files that provide the necessary redirection and maintain virtualization.
You can use ASP.NET to generate the .disco and .wsdl files by hosting your Web service in a virtual directory, such as /SharedServices1/PSI, and then use the Microsoft .NET Framework Web Service Discovery tool (disco.exe) to obtain the generated files.
The steps in Procedure 2 assume that you have installed Project Server in the default directory and show how to generate the .disco and .wsdl files.
Procedure 2: To create the .DISCO and .WSDL files for the Web service:
-
Copy the HelloWorldPSI.asmx file to [Program Files]\Microsoft Office Servers\12.0\WebServices\Shared\PSI.
-
Open the web.config file in the same directory and add the HelloWorldPSI assembly as a child of the <assemblies> tag. The result should have two assemblies, where each assembly is all on one line. Replace the public key token for the HelloWorldPSI assembly with the value of the registered assembly on your Project Server computer (Procedure 1, step 13).
<assemblies>
<add assembly="Microsoft.Office.Project.Server.WebService,
Version=12.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c" />
<add assembly="HelloWorldPSI, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=8e40050454db4aeb" />
</assemblies>
-
Restart Internet Information Services (IIS) (type iisreset in any Command Prompt window).
-
Run the disco.exe command to save the .discomap, .disco, and .wsdl, files to the shared PSI directory. In IIS Manager, check the name of the Shared Services Provider (SSP) in the Office Server Web Services site. If the name is SharedServices1, for example, run the following commands in a Visual Studio 2005 Command Prompt window.
cd [Program Files]\Common Files\Microsoft Shared\web server extensions\12\ISAPI\PSI
disco http://localhost:56737/SharedServices1/PSI/HelloWorldPSI.asmx > results.htm 2>&1
When you run disco.exe in the PSI directory, you do not need to specify the output directory with the /o or /out parameter. If there are errors in the path, file name, namespace, or other properties of the assembly specified in web.config, it is easier to send the standard and error output to a results.htm file and then view it in a browser than to read the HTML code returned in the Command Prompt window. Successful execution of the disco.exe command saves the following output in results.htm.
Microsoft (R) Web Services Discovery Utility
[Microsoft (R) .NET Framework, Version 2.0.50727.42]
Copyright (C) Microsoft Corporation. All rights reserved.
Disco found documents at the following URLs:
http://localhost:56737/SharedServices1/PSI/HelloWorldPSI.asmx?disco
http://localhost:56737/SharedServices1/PSI/HelloWorldPSI.asmx?wsdl
The following files hold the content found at the corresponding URLs:
.\HelloWorldPSI.disco <- http://localhost:56737/SharedServices1/PSI/HelloWorldPSI.asmx?disco
.\HelloWorldPSI.wsdl <- http://localhost:56737/SharedServices1/PSI/HelloWorldPSI.asmx?wsdl
The file .\results.discomap holds links to each of these files.
-
Rename the .disco and .wsdl files in the PSI directory. For example, run the following commands.
ren HelloWorldPSI.disco HelloWorldPSIdisco.aspx
ren HelloWorldPSI.wsdl HelloWorldPSIwsdl.aspx
-
To register namespaces of the Windows SharePoint Services object model, open both the HelloWorldPSIdisco.aspx and HelloWorldPSIwsdl.aspx files, and replace the opening XML processing instruction <?xml version="1.0" encoding="utf-8"?> with the following code.
<%@ 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"; %>
The previous code matches the ASP.NET header in other PSI Web service disco.aspx and wsdl.aspx files in the PSI directory.
-
In the HelloWorldPSIdisco.aspx file, modify the contract reference and SOAP address tags as in the following example. There are two main changes:
Note: |
|---|
|
The code in bold font, such as Service and ServiceSoap, is specific to the Web service name. For example, compare the modified HelloWorldPSIdisco.aspx with Calendardisco.aspx.
|
<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/projectserver/soap/Service/"
binding="q1:ServiceSoap" xmlns="http://schemas.xmlsoap.org/disco/soap/"
/>
<soap
address=<% SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(SPWeb.OriginalBaseUrl(Request)),Response.Output); %>
xmlns:q2="http://schemas.microsoft.com/projectserver/soap/Service/"
binding="q2:ServiceSoap12" xmlns="http://schemas.xmlsoap.org/disco/soap/"
/>
</discovery>
-
In the HelloWorldPSIwsdl.aspx file, make similar substitutions for the SOAP address.
-
Replace the entire soap:address element with the following (all on one line):
<soap:address location=<%
SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(SPWeb.OriginalBaseUrl(Request)),
Response.Output); %> />
-
Replace the entire soap12:address element with the following (all on one line):
<soap12:address location=<%
SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(SPWeb.OriginalBaseUrl(Request)),
Response.Output); %> />
After you complete the steps in Procedure 2, the HelloWorldPSI Web service is available. Because the HelloWorldPSI.asmx file is in the [Program Files]\Common Files\Microsoft Shared\web server extensions\12\ISAPI\PSI directory with the other PSI Web services, it is available to all of the SSP and Project Web Access instances on that computer.
Figure 3 shows the browser view of the Web service with the http://localhost/PWA/_vti_bin/psi/helloworldpsi.asmx URL for the local Project Server computer and the default Project Web Access instance named PWA. If you have a second SSP on the same computer named SSP2 that hosts a Project Web Access instance on port 610 named PWADemo, for example, the URL for remote access of the Web service would be http://ServerName:610/PWADemo/_vti_bin/psi/helloworldpsi.asmx.
Figure 3. Viewing the HelloWorldPSI Web service in a browser