1

I am currently working with WCF services. I am writing both the client (consuming application) and host (services application).

Working on the client, I am writing the code for it, I have 3 options.

  • Add Service Reference to the endpoint in the client
  • Generate service reference using svc util
  • Write the Channel and Service reference etc and share a library between the host and client containing the request and response objects

I am currently leaning towards option 2, using svc util. I have done this in the past with a command similar to this:

svcutil /t:code http://localhost.myapp.com/MyService.svc /out:"..\Folder\MyServiceReference.cs" /n:*,MyNamespace.MyApp.MyService/UseSerializerForFaults /ct:System.Collections.Generic.List`1

From the above, it generates the service reference in to the one class. I would like to be able to modify this so that each class from the service reference generation is added to separate classes. For example, all request objects and generated in to the Request folder, response objects in to Response folder, Channel in to a Channels folder and all other entites in another folder.

Firstly, feedback on the my choice of the second alternative? And also, is it possible to use svcutil to generate classes as outlined above?

amateur
  • 43,371
  • 65
  • 192
  • 320

1 Answers1

0

I generally use svcutil since it gives me more control over the output. However, as far as I know it can only produce a single file.

That being said, I usually wrap my svcutil call in a PowerShell script so that I can clean up/modify the generated code a bit in a repeatable way.

A similar approach could work for you here. I've never tried splitting a file using PowerShell, but I did a quick look around and there are examples on the web. For example: How can I split a text file using PowerShell?

Community
  • 1
  • 1
Mike Parkhill
  • 5,511
  • 1
  • 28
  • 38