Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wsdl.exe/svcutil.exe - is there a way not to generate the classes for types in the xsds during a Web service or client generation

We have a centrally managed object model for types in the schema in C#. We want every one across the enterprise use that object model instead of using the one generated each time from wsdl/svcutil during a webservice client or service implementation.

is there a parameter(any other way) to wsdl/svcutil not to generate classes for the schema types during theie execution?

like image 750
RAVI KANDARPA Avatar asked Feb 16 '10 17:02

RAVI KANDARPA


People also ask

What is SVCUtil exe used for?

Svcutil.exe can be used to download metadata from running services, and save the metadata to local files. To download metadata, you must specify the /t:metadata option. Otherwise, client code is generated. For HTTP and HTTPS URL schemes, Svcutil.exe attempts to retrieve metadata using WS-Metadata Exchange and DISCO.

How do I create a proxy class in WSDL?

After creating the directory we will write a Proxy class by “wsdl” command on a specified location. Just write wsdl and paste your URL that was copied from the web browser of the web service file . asmx and press Enter to create it. It will create a Proxy class on the selected location.

What is SVCUtil dotnet?

The Windows Communication Foundation (WCF) dotnet-svcutil tool is a . NET tool that retrieves metadata from a web service on a network location or from a WSDL file, and generates a WCF class containing client proxy methods that access the web service operations.


2 Answers

I believe what you are looking for is: svcutil.exe /r your-dtos.dll

/reference: - Reference types in the specified assembly. When generating clients, use this option to specify assemblies that might contain types representing the metadata being imported. (Short: /r)

In my opinion the tight coupling of the WCF proxy, endpoint channel, service operations and dto payloads into the same generated client proxy is a major design flaw.

This is what spurred me to solve in my open web services framework where I decouple the end point and payload which allows:

  • The same web service client (i.e. Soap11, Soap12, XML, JSON) to be able to call any web service.
  • It lets me also use the same DataContract dto instance in any of the web service clients
  • This has many benefits including being able to expose the same web service on a number of different end points without any extra configuration. Thus providing optimized web service endpoints for each consumer of my service. E.g.
    • XML for interoperability and strongly-type clients,
    • JSON for Ajax clients,
    • WSDL's for environments that prefer generated code (i.e. Flex Builder, VS.NET 'Add Service Reference' etc)

At my company we have developed hundreds of web services called by a number of different clients i.e. Ajax, Flash/ActionScript, C++, Silverlight, ASP.NET and being able to call the same web service through different endpoints has saved us countless hours.

like image 169
mythz Avatar answered Oct 23 '22 04:10

mythz


I don't know of any specific setting or command line switch to enforce this - what you can do, but that's mostly a matter of training and enforcing by checking, is to share the class library (the assembly, in a DLL) with the developers, and make sure that everyone references that common class library and leaves the default settings in the "Add Service Reference" dialog (on the "Advanced" page) alone:

alt text

Here, you define that WCF will reuse any types it can find in any of the referenced assemblies - so if your developers add a regular reference to the common data contracts library, then WCF will use those types instead of re-creating them over and over again.

But again - that's only a "management by example and checking" kind of approach - I don't know of any technical way to enforce this.

like image 30
marc_s Avatar answered Oct 23 '22 03:10

marc_s