Service hosting with WCF from WSDL - SVCUtil creates verbose types for methods

I have a WSDL file from a published ASMX web service. That I then creates a service layout that mimics a real service for testing purposes.

From WSDL, I used SvcUtil.exe to generate the code. Apparently, it also generates a server-side interface.

Well, the problem is that it creates very short interfaces. For example, the int Add(int, int) method is displayed in the generated .cs file as AddResponse Add(AddRequest) . AddRequest and AddResponse have AddRequestBody and AddRequestResponse and so on.

The problem is that for implementation, I need to create body and response instances for each method, even when I just want to return a simple int result.

Why can't it correctly generate the method signature? Is there a better way to create WCF-side interfaces / contracts from WSDL?

+3
source share
1 answer

The structure of the message you are describing is caused by two things:

  • improved compatibility between web service stacks and their software models (RPC vs messaging);
  • flexibility to accommodate new parameters in existing web services.

You are not the first to complain about him, or the last . This is the WSDL binding style, commonly called a document / literal wrapped template . It creates documentary / literal web services and also supports the RPC programming style. This is very " WS-compatible ", so to speak ...

The WS-I Basic profile states that soap:body should have only one child, in which case it is the wrapper for the name of the operation that is being called. Call parameters are packaged into only one element as best practice, since it is more flexible for subsequent changes . In the case of WCF, you usually get a MessageContract that has one MessageBodyMember that wraps all parameters.

Basically, you see the results of battles in web services that have been going on for a long time.

Here are a few additional readings on the topic (and this is just the tip of the iceberg):

+4
source

All Articles