SPDev – GenWS
This page covers the GenWS operation in the SPDev command line utility.
SPDev – Generate Web Service (GenWS)
Create SharePoint Web Service .ASPX Files Automatically.
The SPDev -o GenWS operation will auto-generate the web service WSDL.aspx and Disco.aspx files needed for a custom SharePoint web service.
Automatically generate your SharePoint disco.aspx and wsdl.aspx files in seconds!
No need to manually copy or deploy your .asmx first!
No manual editing!
No Disco.exe needed!
Automatically recycles the application pool (ensuring the newest assembly is loaded)!
Automatically deploys the final SharePoint web service files (using the -deploy option)!
Automatically deploys your assembly to the GAC (using the -gac option)!
No UI to enter data each time. A command tool you can script for fast, consistent re-use!
After having to manually modify the disco.aspx and wsdl.aspx files by hand for the last three years, I finally found it tedious enough to create this utility. There are other tools out there, but they require you to enter information into a Windows UI, they are not script-able, and still felt a bit tedious for me. Call me lazy. :) Time is money.
This tool is a command line utility. Simply execute the SPDev.exe command and your MyServiceDisco.aspx and MyServiceWsdl.aspx files are immediately ready for deployment. SPDev also allows you to script the process. Create a .cmd or .bat file and you’ll never have to enter any parameters again. Another big benefit is you don’t need to use the Disco.exe utility. This is because SPDev uses IIS and .NET instead which will always be on your development machine – since you are developing for SharePoint. And, there are no temp files generated (unless you want them generated, say for debugging).
SPDev Usage Overview
Below are the suggested steps you will need to complete to generate your custom SharePoint web service .aspx files.
- Build your Visual Studio project to generate your web service assembly (.dll) file.
- Copy your assembly to the Bin or GAC. (SPDev can even do this for you, if you like!)
- Execute the SPDev.exe command to generate the web service files.
Sample Batch/Script Command (.cmd) File
Before you can generate the standard DISCO and WSDL files needed for any web service, you must deploy your assembly to either the Bin folder or to the Global Assembly Cache (GAC). Below is an example of a command (.cmd) file you can use to automatically add your assembly to the GAC and then generate your SharePoint web service (.aspx) files using the SPDev utility. This example also uses the optional -deploy parameter to automatically deploy the final SharePoint web service files to the standard SharePoint web services ISAPI (_vti_bin) folder on your local development machine – for quick and immediate use by the developer.
Note: the path specified in the example below for the GacUtil.exe may be different for your machine.
Sample SPDev-GenWS.cmd script:
@echo GAC Assembly
SPDev.exe -o Gac -file MyService.dll
@echo Generate SharePoint web service files using SPDev Utility
SPDev.exe -o GenWS -url http://localhost -asmx MyService.asmx –deploy
SPDev Command Syntax
Here is the SPDev command syntax help, which provides an overview of what the command provides.
SPDev GenWS Operation Syntax
SPDev -help GenWS
SPDev, 18.104.22.1683, Created by Mark Wagner
Generates the SharePoint web service disco.aspx and wsdl.aspx files.
* No need to manually edit your .disco and .wsdl files to work with
SharePoint. This generates the final disco.aspx and wsdl.aspx files
SPDev.exe -o GenWS -url -asmx
Specifies the url to the SharePoint web application. This only needs
to be the URL to the root web application site. A url value of
http://localhost may be used for easy use by several developers.
Specifies the web service .asmx file name. This may be an absolute or
Saves the standard .disco and .wsdl generated files to the Temp folder.
These are the standard non-SharePoint web service .disco and .wsdl files,
which are used to create the final SharePoint disco.aspx and wsdl.aspx
web service files. A subfolder named “Temp” is created.
Specifies a custom path to use for temporary files. When omitted, a
subfolder named “Temp” is created, if the -tempfiles option is specified.
May be a relative or absolute path.
Specifies a custom path to place the generated SharePoint web service
.aspx files. When omitted, the path defaults to the current execution
folder. May be a relative or absolute path.
Copies the generated web service disco.aspx and wsdl.aspx files to the
standard web services SharePoint ISAPI (_vti_bin) folder.
IMPORTANT: This is not the recommended deployment method for
Additional Arguments (available with any operation):
Displays stack track for any exception message to the console.
Pauses the command on completion. Press any key to continue.
SPDev.exe -o GenWS -url http://localhost -asmx My.asmx
SPDev.exe -o GenWS -url http://localhost -asmx My.asmx -deploy
SPDev.exe -o GenWS -url http://localhost -asmx My.asmx -tempfiles -debug
General Web Service Trouble Shooting Tips
Below are common web service trouble shooting tips. These are relevant to web services in general and not issues caused by the SPDev utility.
Unable to load assembly, or assembly not found error (or something like this)
- Tip: Try specifying the strong class name in your .asmx file in the class attribute.
If you have something like this: Class=”WebService1.Service1″
Try using the strong class name for your web service class similar to this:
Class=”WebService1.Service1, Service1, Version=22.214.171.124, Culture=neutral, PublicKeyToken=bc8b106c76sample”
SPDev GenWS Trouble Shooting Tips
- Tip: Remember that SPDev’s GenWS operation has an optional –tempfiles parameter. This will save the standard .disco and .wsdl files generated by your web server to a “temp” subfolder. These should look like standard (non-SharePoint) web service files – the files you normally have to modify manually. If these files do not look correct, review them to see if they contain any error message information that may be helpful in determining the cause.
Error: Web Service disco is not a valid Disco File.
Error: Web Service wsdl is not a valid WSDL File.
- Tip: This error is likely caused by your web services assembly and/or .asmx file not being deployed correctly. Be sure your assembly is properly deployed to either the Bin or GAC before executing the SPDev command.
- Tip: Try resetting IIS in case something else has a lock on your assembly. I have experienced this happing (occasionally) where my Visual Studio environment has held a lock on my pre-existing assembly preventing a new version of the assembly from being deployed to the GAC. In this case, you may want to try closing Visual Studio and then resetting IIS. You will need to re-GAC your newest assembly once the old assembly has been unlocked.