Source of the problem
Recently used in the project WCF, because is a novice, is always more awe-inspiring new things, but everything is going very smoothly, when running, suddenly reported wrong, the compiler prompted the error is probably:"InvalidOperationException: Unable to load operation" Uploadresourcenotindb ", which has a parameter or return type of type System.ServiceModel.Channels.Message, or has a messagecontractattribute and other types of different type parameters. "!
Service contract and message contracts (messages contract) are as follows:
1[ServiceContract (Name ="Resourcefile")]2 Public InterfaceIsysresourcesyncservice:ibaseservice3{/// <summary>4 ///synchronization to the server side, will not be logged to the database, just synchronize files to the server side5 /// </summary>6 /// <param name= "Resourcefile" ></param>7 8 [OperationContract]9 voiduploadresourcenotindb (resourcefile resourcefile);Ten } One A [MessageContract] - Public classResourcefile - { the [Messagebodymember] - PublicStream Resourcebody {Get;Set; } - - [MessageHeader] + Public stringresourcename {Get;Set; } - + [MessageHeader] A Public stringResourcePath {Get;Set; } at - [MessageHeader] - Public stringreflectentity {Get;Set; } - - [MessageHeader] - Public stringFieldName {Get;Set; } in - [MessageHeader] to Public intEntityId {Get;Set; } +}
Problem Finder
To look for different information, found in http://msdn.microsoft.com/zh-cn/library/ms730255.aspx, found the problem solution.
English Analysis:
A Messaging-style operation have at the most one parameter and one return
Value where both types is message types; That's, they serialize
Directly into a specified SOAP message structure. This is any type
marked with the MessageContractAttribute or the Message type.
Chinese analysis:
That is, if a service contract (service contract) is based on the message type (Messaging-style), the service operation (operation) must:
There is at most one input parameter
There is at most one return type
The input parameter and the return type must be of the message type (message type, such as an argument for a messaging contract or a msg). Of course it can not be returned as void.
The meaning is very clear, then begin to revise!
Solutions
Change the return bool back to void or message type! Perfect Operation !
Expand your knowledge
In addition, when you define a message contract that is applied to the flow (stream) transport (Messages contract):
One, the SOAP body (that is, the property applied by [Messagebodymember]) can have only one, that is, public System.IO.Stream FileData {get; set;}
Second, the SOAP header (that is, [MessageHeader] applied properties) can have multiple, transfer file name, size, time and so on.
To improve performance, multiple headers can be synthesized in one header, and data contract must be used to synthesize multiple data.
Error parsing of WCF return value