This article is a mirror article of machine translation, please click here to jump to the original article.

View: 16868|Reply: 0

[WCF/Web Servics] The operation 'xxx' could not be loaded because it has a parameter or retu...

[Copy link]
Posted on 7/20/2016 10:59:59 AM | | |
The operation 'xxx' 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.

I wrote an interface to upload files in WCF and want to return the upload result, the interface is as follows:



At this time, the run will report an error if it is written as follows:



Errors will also be reported when running!!!!

As we said earlier, what is duplexing, there is a back-and-forth, right? Yes, the above method has incoming parameters and return values, there are comings and goings, it is duplex, why not?

Haha, the problem is that we use the message protocol, under this premise, our method cannot be defined casually, using the message protocol method, if:

a. If the message contract is used as an incoming parameter, there can only be one parameter, and the following definitions are incorrect:

void Reconcile(BankingTransaction bt1, BankingTransaction bt2);

b. Unless you return void, if not, then you must return a message contract, bool UpLoadFile(TransferFileMessage tMsg) Our definition obviously does not meet the requirements.

So how to solve it? We need to define another message contract for returning.


Roughly speaking, you can't use bool, string, etc. as return values, you can set void no return value type.

However, I wonder what if there is a return value???? The solution is as follows:









Previous:WCF error: 413 Request Entity Too Large
Next:WCF implementation file upload has a return value for demo download
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com