Wsdl.exe / svcutil.exe - is there a way to not generate classes for types in xsds during web service or client creation

We have an object oriented centralized model for types in a C # schema. We want everyone in the enterprise to use this object model instead of using the one generated each time from wsdl / svcutil during a web service or service implementation.

Is there a parameter (in any other way) in wsdl / svcutil to not generate classes for schema types at runtime?

+6
source share
3 answers

I donโ€™t know of any specific setting or command line parameter to ensure this - what you can do, but it is mainly a matter of training and application by checking, is to share the class library (assembly in the DLL) with the developers, and make sure that everyone references to this shared class library and leave the default settings only in the "Add Service Link" dialog box (on the "Advanced" page):

alt text

Here you specify that WCF will reuse any types that it can find in any of the mentioned assemblies - therefore, if your developers add a regular link to the library of common data contracts, then WCF will use these types instead of re-creating them again and again. again.

But then again - this is just an example-based management and verification approach - I donโ€™t know a single technical way to ensure this.

+3
source share

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

/ reference: - The types of links in the specified assembly. When creating clients, use this option to specify nodes that may contain types that represent imported metadata. (Short: / g)

In my opinion, the tight connection of the WCF proxy server, the endpoint channel, service operations and data with useful data in the same client proxy server created is the main design flaw.

This is what prompted me to decide in my open web services infrastructure , where I separate the endpoint and the payload, which allows:

  • The same web services client (i.e. Soap11, Soap12, XML, JSON) to be able to call any web service.
  • It allows me to also use the same instance of the DataContract dto in any of the web service clients.
  • This has many advantages, including the ability to expose the same web service to several different endpoints without any additional configuration. This ensures that the endpoints of the web service are optimized for each user of my service. For example.
    • XML for interoperability and strict type of clients,
    • JSON for Ajax clients,
    • WSDL for environments that prefer generated code (i.e. Flex Builder, VS.NET 'Add Service Reference', etc.)

In my company, we have developed hundreds of web services called several different clients, that is, Ajax, Flash / ActionScript, C ++, Silverlight, ASP.NET and the ability to call the same web service through different endpoints, including

+3
source share

If you remove the mex endpoint from the service configuration file, the client application will not be able to detect and generate proxy objects.

A way to deal with this situation, if I understand your question correctly, you need to do the following:

  • Create a shared DLL set that has the service and a datacontracts / shared object model.
  • Create a service using contracts in a shared dll, not Visual Studio creates contracts when creating a new service.
  • Remove the MEX endpoint from the server configuration file (this will significantly damage proxy generation).
  • Ask your client to use a common dll and manually create channels on the client side (through the factory channel, etc.).

In this approach, you do not use wsdl.exe / svcutil.exe at all, since you basically bypass wsdl. You do not add service links because you manually manage the connections.

EDIT: after this approach, the client can still try to create proxy objects via wsdl.exe / svcutil.exe, but they will not get the correct information from wsdl. They will essentially generate a broken / incomplete proxy.

0
source share

All Articles