Reputation: 1240
I have a WSDL file from a published ASMX web service. What I am after is creating a mock service that mimics the real service for testing purposes.
From the WSDL, I used SvcUtil.exe to generate code. Apparently it also generates the server side interface.
Well the issue is that it generates very chunky interfaces. For example, a method
int Add(int, int)
is showing up in the generated .cs file as AddResponse Add(AddRequest)
. AddRequest
and AddResponse
have a AddRequestBody
and AddRequestResponse
and so on.
The issue is that, to implement, I need to create the body and response instances for each method, even when I just want to return a simple int
result.
Why can't it generate the method signature properly? Is there a better way of generating WCF Server side interface/contracts from WSDL?
Upvotes: 3
Views: 1138
Reputation: 24590
The message structure you are describing is caused by two things:
You are not the first one to complain about it, or the last. It's a WSDL binding style commonly called the document/literal wrapped pattern. It produces document/literal web services and yet also supports an RPC programming style. It's very "WS interoperability friendly", so to speak...
The WS-I Basic profile specifies that the soap:body
must have only one child element and in this case it's a wrapper for the operation name that's being invoked. The parameters of the call are packed into only one element as a best practice since it's more flexible to later changes. In case of WCF you usualy end up with a MessageContract which has one MessageBodyMember which wraps all the parameters.
Basically, you are seeing the results of web service battles fought long time ago.
Here is some extra reading on the subject (and that's just the tip of the iceberg):
Upvotes: 4