CAA Web Services Home |
|
Generating a C# Client BindingHow to use WSDL and XSD definitions to generate C# client bindings for CAA Web services |
Technical Article |
AbstractThis article introduces the .NET Framework Web Services support and explains how to use the Web Services Description Language Tool (wsdl.exe) in order to generate C# client bindings for CAA Web services. These bindings can be used to create client applications that interact with CAA Web services. |
The .NET Framework natively provides support to build Web services, as well as to consume them. In the context of CAA Web services, only the client side feature of the .NET Framework is required:
Note: If you have already installed Microsoft Visual Studio .NET 2003, you do not need to install the .NET Framework SDK separately. Visual Studio .NET 2003 includes the SDK.
The wsdl.exe tool shipped with the .NET Framework 1.1 suffers from a limitation. It does not support WSDL
documents containing WS-I conformance claims, even though the use of the related XML elements
are officially documented in the WS-I Basic Profile [1]. As a
consequence, if you try to generate a C# proxy using the wsdl.exe tool using one of the CAA Web services WSDL
documents, it will issue an error. Fortunately, this particular wsdl.exe issue has been fixed with .NET
Framework 1.1 Service Pack 1. As a consequence, this level is the offical minimal prerequisite when
trying to generate a C# proxy for CAA Web services.
Without Service Pack 1, the workaround would consist in the following steps:
The sample WSDL document below highlights the WS-I conformance claims which is contained in the wsdl:documentation element and that must be removed:
<?xml version="1.0" encoding="UTF-8" ?>
|
You can refer to the .NET Framework documentation for further details on Web services related topics. See [3] for access to some accurate links on the MSDN Web site.
[Top]
The term "certified" is intended to describe the fact that a given .NET Framework release has been successfully tested and validated in order to consume CAA Web services. As of now, the certified release requires:
[Top]
Before using wsdl.exe to create the C# proxy, it is important to get an understanding of some of the concepts that are related to the WSDL documents describing the available CAA Web services. See [4] for an overview of these concepts.
[Top]
As detailed in the following section, there is not much difference between using either the WSDL interface document or the WSDL implementation document as input of the wsdl.exe tool (unlike what can be observed with the Axis WSDL2Java compiler for example). There are several ways available to access these WSDL documents:
file
servlet to access all of
the files delivered in the runtime view. You can refer to [5] for the description of
the URI scheme providing access to each available WSDL interface document,
wsdl
servlet to
dynamically generate the content of the WSDL implementation documents. These files are not physically delivered
in the file system, because they contain deployment specific information. You can refer to [6]
for the description of the URI scheme providing access to each available WSDL
implementation document.
The remote location approaches are typically useful if you do not have access to the file system of the product installation (for example, it may be the case for security considerations).
In order to use the wsdl.exe tool, you need to open up a command prompt. Click on Start -> Run and then type cmd. From the prompt, browse to the \Bin directory of your .NET Framework 1.1 SDK installation. By default, it is located in the C:\Program Files\Microsoft.NET\SDK\v1.1\Bin directory. For details on the wsdl.exe tool options, you can issue the following command: wsdl /?.
You are now ready to invoke the wsdl.exe tool, providing as input the WSDL document describing the CAA Web service you wish to consume:
wsdl /namespace:<Namespace> /out:<Filename>
<WSDL-document>
|
<Namespace>
: the namespace for the generated C# proxy class,
<Filename>
: the filename of the generated C# proxy class,
<WSDL-document>
: the path or URI of the input WSDL document (as explained above).
When the WSDL document is accessed from a remote location using the HTTP protocol, it may be required
to set security settings for the wsdl.exe tool. This is typically the case when the remote server is secured
using Basic Authentication. In such case, you need to provide two extra parameters:
wsdl /namespace:<Namespace> /out:<Filename>
/username:<Username> /password:<Password>
<WSDL-document>
|
<Username>, <Password>
: valid set of credentials for Basic
Authentication.
Upon successful invocation, you should receive the following message at the command prompt: Writing file 'XXX.cs', where XXX is the name of the file provided as input of the wsdl.exe tool:
![]() |
[Top]
The wsdl.exe tool always generates a single source file for each WSDL document used as input, no matter its type
(WSDL interface document versus WSDL implementation document). The generated file contains a proxy class that
defines both synchronous and asynchronous methods for each operation defined in the WSDL document. For example,
when the IApplicationBinder.wsdl WSDL interface document defines the getUserContexts
operation, wsdl.exe generates the following methods: bindToApplication
,
BeginbindToApplication
and EndbindToApplication
. The first method can be used to
interact with the target CAA Web service synchronously, and the other ones can be used to interact with it
asynchronously.
The wsdl.exe tool generates almost the exact source code when using the WSDL interface document as input than when using the WSDL implementation document. The only differences are:
namespace com.dassault_systemes.caaplmsecurity.caaenoposappbinderdotnet1_1clientbase.enoposapplicationbinderimpl {
|
namespace com.dassault_systemes.caaplmsecurity.caaenoposappbinderdotnet1_1clientbase.enoposapplicationbinderimpl {
|
Aside from the proxy class itself, wsdl.exe also generates the type mapping between XML structures and C# objects. For every complexType element defined in the XSD referenced by a given WSDL interface document, wsdl.exe generates the corresponding C# class in the same namespace than the C# proxy one. The XSD types are directly mapped to .NET types when available. The example below describes how a given complexType referenced in the IApplicationBinder.wsdl file is mapped to its corresponding C# equivalent:
Complex type definition defined in PPRGenericWS.xsd:
<xsd:complexType name="Identifier">
|
Corresponding C# class generated by wsdl.exe:
[System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:com:dassault_systemes:PPRGenericWS")]
|
[Top]
A C# client binding (or proxy class) can be generated for CAA Web services using the Web Services Description Language Tool (wsdl.exe). You must use apply the Service Pack 1 to your Microsoft .NET Framework 1.1 + SDK installation in order to avoid the issue of the wsdl.exe tool that fails to understand WS-I conformance claims contained in the WSDL interface documents describing the available CAA Web services.
The generated C# client binding can be used to consume the related CAA Web service implementations that have been deployed on a target application server. For more details, please refer to the use cases describing how to consume the CAA Web services you wish to use.
[Top]
[1] | WS-I Basic Profile 1.0 |
[2] | DeDoc Tool |
[3] | .NET Framework Developer's Guide |
[4] | CAA Web Services and WSDL Definitions |
[5] | WSDL Interface Documents |
[6] | WSDL Implementation Documents |
Version: 1 [Jan 2006] | Document created |
[Top] |
Copyright © 1994-2006, Dassault Systèmes. All rights reserved.