SPDev – GenWS

This page covers the GenWS operation in the SPDev command line utility.

SPDev – Generate Web Service (GenWS)
Operation: GenWS

Create SharePoint Web Service .ASPX Files Automatically.

Overview

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.

  1. Build your Visual Studio project to generate your web service assembly (.dll) file.
  2. Copy your assembly to the Bin or GAC. (SPDev can even do this for you, if you like!)
  3. 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, 1.3.10.503, Created by Mark Wagner

-o GenWS
     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
     automatically.
Usage:
  SPDev.exe -o GenWS -url -asmx

    Parameters:
     -url
       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.

     -asmx
       Specifies the web service .asmx file name. This may be an absolute or
       relative path.

     [-tempfiles]
       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.

     [-temppath]
       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.

     [-outpath]
       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.

     [-deploy]
       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
       production environments.

Additional Arguments (available with any operation):
     [-debug]
       Displays stack track for any exception message to the console.

     [-pause]
       Pauses the command on completion. Press any key to continue.

Examples:
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=1.0.0.0, Culture=neutral, PublicKeyToken=bc8b106c76sample”

SPDev GenWS Trouble Shooting Tips

Debugging?

  • 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.

12 thoughts on “SPDev – GenWS

  1. Mark, Is it possiable to use this tool if a I am developing in the cleint machine and not in the sharepoint machine ?
    I tried and I am getting an error
    Could not load file or assembly ‘Microsoft.Sharepoint.

    • Hi Lisa,
      The SPDev utility will only work directly on a machine with SharePoint installed. The error (“Could not load file or assembly ‘Microsoft.Sharepoint”) you are getting is likely because you don’t have SharePoint installed on that machine. SPDev calls the SharePoint assemblies directly to perform its actions; it does not make remote web service calls.

      Just curious. Are your trying to use the GenWS operation, or are you interested in using one of the other operations?

  2. Getting below Error when i use in sharepoint 2010 environment.

    Generating .disco and .wsdl files…The remote server returned an error: (404) N
    ot Found.

    Please advise me further if possible.

    Thanks in Advance.

  3. Getting error “Could not load file or assembly ‘Microsoft.Sharepoint…….” But the server has SharePoint installed – confirmed. For example http://:port//default.asax returns a sharepoint page. Question is how to find the application root url for the sharepoint server, which will be used in SPDev GenWS ?

    Thanks

  4. Getting error “Could not load file or assembly ‘Microsoft.Sharepoint…….” But the server has SharePoint installed – confirmed. For example http://://default.asax returns a sharepoint page. Question is how to find the application root url for the sharepoint server, which should be used for SPDev GenWS -url ?

    Thanks

  5. Hi, i get the MSG and shared with my partners. The console show:

    C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\Projects
    \CustomService_v3\CustomFolderSP\bin\Debug>SPDev.exe -o GenWS -url http://jramos
    -psowbx60/ -asmx SPFolderWS.asmx -deploy
    SPDev – SharePoint Developer Utility
    Version: 1.3.9.1210
    Created by Mark Wagner
    License HERE
    SPDev generating SharePoint web service files:
    Copying .asmx file to working folder… done.
    Recycling the application pool ‘SharePoint – 80’… done.
    Generating .disco and .wsdl files…done.
    Web service .disco file is not a valid DISCO file. File SPFolderWS.disco saved i
    n the temp folder.

    I copy and paste the 10 first lines of the file:

    Error

    I hope can you help me. Thanks.
    Regards.

  6. ……..
    SPDev – SharePoint Developer Utility
    Version: 1.3.9.1210
    Created by Mark Wagner
    License HERE
    SPDev generating SharePoint web service files:
    Copying .asmx file to working folder… done.
    Recycling the application pool ‘SharePoint – 80’… done.
    Generating .disco and .wsdl files…The remote server returned an error: (500) I
    nternal Server Error.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s