Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Message or a type that has MessageContractAttribute and other parameters of different types

Tags:

wcf

I'm developing WCF services where some classes have the [MessageContract] attribute, and some don't.

When I try to run the services I get this error message below:

The operation 'ProcessOperation' 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.

Does it mean that all the services must have [MessageContract] although they are not related?

like image 354
Nil Pun Avatar asked Jun 30 '11 05:06

Nil Pun


2 Answers

No, it means that you have multiple parameters on the method and some of them are not messages. Try posting the interface to your service.

This blog post explains:

... problem is that message contracts cannot be used at the same time as other parameter types. In this case, the return value of the operation is a string. Return values are just another output parameter, so this operation is mixing a message contract message with a primitive parameter type. This fails because message contracts give you control of the layout of the SOAP message, preventing the system from melding in these additional parameters.

Important note:

By the way, the error message you get when you try to mix message contracts looks like this.

like image 155
faester Avatar answered Nov 11 '22 01:11

faester


This basically means that a particular operation is using a combination of message contract types and primitive types in any of the following combinations:

MixType1: Contract type and primitive types as operation parameters
MixType2: Contract type as a parameter and primitive type as return type
MixType3: Primitive type as a parameter and Contract type as return type

Any of the scenarios listed above would generate the error.

like image 24
Alberto Montellano Avatar answered Nov 11 '22 01:11

Alberto Montellano