30.03.2009 г.

Important when using MessageContract as parameter in an operation

Today, while trying to create a reference to a WCF service I got the following exception:
The operation 'xxxxxxxx' could not be loaded because it has a parameter or return type of type System.ServiceModel.Channels.Message or a type that has MessageContractAttribute and other parameters of different types. When using System.ServiceModel.Channels.Message or types with MessageContractAttribute, the method must not use any other types of parameters.

It is quite obvious from the exception message what was wrong in my service, that was the obstacle in the creation of a service proxy.
In WCF there is a limitation that if you use a type that is marked with a MessageContract attribute as a return value or operation parameter, it is obligatory that all the parameters and return value(if present) should be types marked with that attribute too.

Also it is recommended as a good practice to encapsulate all operator parameters in a single message contract.

In my case the mistake was that I had an operation with a return type of 'bool' and taking a parameter that was tagged with a MessageContractAttribute attribute.

5 коментара:

  1. Brim over I acquiesce in but I dream the collection should have more info then it has.

    ОтговорИзтриване
  2. I wish not approve on it. I assume precise post. Particularly the title attracted me to read the unscathed story.

    ОтговорИзтриване
  3. Amiable brief and this mail helped me alot in my college assignement. Say thank you you seeking your information.

    ОтговорИзтриване
  4. Easily I agree but I contemplate the brief should secure more info then it has.

    ОтговорИзтриване
  5. Do you have copy writer for so good articles? If so please give me contacts, because this really rocks! :)

    ОтговорИзтриване