Sergey Shishkin

on agile software development

WCF: Actions, Asterisk and Metadata

WCF tool svcutil.exe can generate code and configuration based on WSDL. This tool is mostly used for client-side programming to create a proxy. The same functionality can also be used to generate a service contract when implementing some WSDL-described standard (contract-first development). However, the code that is generated by the svcutil.exe is not always suitable for a service-side contract.

For a better compatibility (I think) svcutil.exe disables SOAP Action header check for the reply messages. This is done by setting the OperationContractAttribute.ReplyAction property to asterisk (*):

[System.ServiceModel.OperationContractAttribute(Action = "", ReplyAction = "*")]


[return: System.ServiceModel.MessageParameterAttribute(Name = "Response")]

MethodResponse Method (MethodRequest Request);

The same asterisk has, actually, different meaning for the service-side contract: it “instructs WCF not to add a reply action to the message, which is useful if you are programming against messages directly” (according to MSDN). By the way, Action and ReplyAction properties don’t default to asterisk rather to “<namespace>/<service>/<operation>[Response]”.

Setting the Action property to an asterisk is another story. It indicates the method that will be used to handle all unmatched incoming messages (not referring to operations with explicit action). See MSDN Reference for more information.

Moreover, WsdlExporter, which is used for metadata publishing, ignores operations with asterisk actions (both Action and ReplyAction). Precisely speaking, it ignores operation contracts that have either input or output message with asterisk action. This leads to publishing metadata with empty service contract (with no operations in it). Although, messages conforming to the original WSDL can be successfully received, dispatched and handled by the service without any problem.

So, be aware of that interesting facts and pay attention to the auto-generated code, especially to those Action and ReplyAction properties.

Written by Sergey Shishkin

21.03.2007 at 13:10

Posted in Uncategorized

%d bloggers like this: