Visual C++ Concepts: Adding Functionality
SPROXY.EXE: XML Web Service Proxy Generator

SPROXY.EXE is a command line tool that generates native C++ client code for accessing an XML Web service based on a WSDL description.

This tool is used by the Visual C++ project system when a Web reference is added to a native C++ project using the Add Web Reference Dialog Box or when Tool is set to Web Service Proxy Generator and Generated Proxy Language is set to Native C++ in the settings for a file.

The command line syntax is shown below:

sproxy [ options ] [ /out:outputfile ] input_location

Parameters

options
(Optional) One or more of the following:
Option Description
/? or /help Display usage information.
/nologo Suppress copyright message.
/nowarn Disable all warnings.
/nopragma Do not inject "#pragma once" into output file.
/noclobber Do not overwrite output file if it already exists.
/nonamespace Do not inject a C++ namespace into the generated proxy file. By default, SPROXY injects a namespace based on the WSDL service name.
/namespace:<name> Inject a namespace named <name> into the generated proxy file. By default, SPROXY injects a namespace based on the WSDL service name.

The namespace must be a valid C++ identifier. The /namespace:<name> option has the same effect as /nonamespace when <name> is empty.

/wsdl <input_location> Process the .wsdl file at the specified path <input_location> rather than a .discomap file (default).
outputfile
(Optional) The name of the file to which the generated code will be written. If the file exists, it will be overwritten unless /noclobber is specified. If outputfile is not specified, SPROXY will create a file in the current directory based on the WSDL service name.
input_location
The location of the file describing the XML Web service for which to generate proxy code. input_location can be a URL or file system path to a .discomap or .wsdl file. Specify the /wsdl option when you use a .wsdl file.

SPROXY.EXE can also process a results.discomap file. Note that the .discomap file contains a link to a local copy of the .wsdl file and uses a local copy of the schema file.

Remarks

SPROXY.EXE will generate a proxy class template derived from >CSoapRootHandler and its template argument. The template argument needs to conform to the >SOAP client archetype and defaults to >CSoapSocketClientT<>.

Each SOAP method exposed by the service will be represented by a method in the proxy class. To access the XML Web service, create an instance of the proxy class and call the appropriate method.

SPROXY.EXE can be found in the \vc7\bin directory of your Visual C++ installation.

See Supported Types and Supported Types in XML Web Services Created with ATL Server for a list of types supported by SPROXY.

Note   The SPROXY-generated client requires MSXML3. Before running the client, you will need to install MSXML3 on the machine on which the generated client is installed.
Xmlinst.exe installs MSXML3 in replace mode. Download the Xmlinst.exe Replace Mode Tool from MSDN at http://msdn.microsoft.com/downloads/default.asp?URL=/code/sample.asp?url=/msdn-files/027/001/469/msdncompositedoc.xml.
For information about using Xmlinst.exe, see the Knowledge Base article "PRB: Application Errors Occur After You Run Xmlinst.exe on Production Servers" (Q278636). You can find Knowledge Base articles on the MSDN Library CD-ROM or at http://support.microsoft.com/support.
For information on running MSXML3, see >Running MSXML 3.0 in Replace Mode.
Note   The SPROXY-generated header file includes atlsoap.h. This file declares [emitidl("restricted")];. If IDL emission is restricted when a [module] attribute is encountered, an error will occur. You can enable IDL emission by using [emitidl("true")]; in your code after including atlsoap.h. (atlextmgmt.h includes the same emitidl declaration as atlsoap.h, so the same issues apply.)
Note   The SPROXY-generated methods do not check pointer parameters for NULL before dereferencing. Check pointers for NULL before passing them to methods in the XML Web service proxy class.

Example

The following command line will generate a file, myservice.h, containing C++ proxy code for accessing the XML Web service described by the WSDL obtained from http://myserver/myservice.dll?Handler=GenMyServiceWSDL:

sproxy /wsdl http://myserver/myservice.dll?Handler=GenMyServiceWSDL /out:myservice.h

The following command line will generate an output file containing C++ proxy code for accessing the XML Web service described by the WSDL obtained from results.discomap (which contains a link to a local copy of the .wsdl file):

sproxy results.discomap

For more examples of code that uses a proxy class generated by SPROXY, see SOAP Client Code and see the DataSetConsumer Sample.

See Also

XML Web Services Created with ATL Server | Providing XML Web Services | Consuming XML Web Services | SOAP Samples

Page view tracker