WCF method showing invalid parameters
I have a WCF service, in it i have a method that takes a MessageContracts as input parameter and returns a MessageContract as out parameter. Please find the method defination below
[OperationContract(IsOneWay = false)]
FileDownloadReturnMessage DownloadFile(FileDownloadMessage request);
But when i cr开发者_JS百科eate the proxy on the client and try to access this method i get a different definition of the method. Below is what i see when i try to access the method
DownloadFile(FileMetaData metadata, out stream outStream)
Complete code of the web service is below :
[ServiceContract(Namespace = "http://schemas.acme.it/2009/04/01")]
public interface IFileTransferService
{
[OperationContract(IsOneWay = false)]
FileDownloadReturnMessage DownloadFile(FileDownloadMessage request);
[OperationContract()]
string HellowWorld(string name);
}
[MessageContract]
public class FileDownloadMessage
{
[MessageHeader(MustUnderstand = true)]
public FileMetaData FileMetaData;
}
[MessageContract]
public class FileDownloadReturnMessage
{
public FileDownloadReturnMessage(FileMetaData metaData, Stream stream)
{
this.DownloadedFileMetadata = metaData;
this.FileByteStream = stream;
}
[MessageHeader(MustUnderstand = true)]
public FileMetaData DownloadedFileMetadata;
[MessageBodyMember(Order = 1)]
public Stream FileByteStream;
}
[DataContract(Namespace = "http://schemas.acme.it/2009/04/01")]
public class FileMetaData
{
public FileMetaData(string [] productIDs, string authenticationKey)
{
this.ids = productIDs;
this.authenticationKey= authenticationKey;
}
[DataMember(Name = "ProductIDsArray", Order = 1, IsRequired = true)]
public string[] ids;
[DataMember(Name = "AuthenticationKey", Order = 2, IsRequired = true)]
public string authenticationKey;
}
Please advise.
By default proxy doesn't use message contracts so when you generate proxy for service using message contracts it unwraps them and containing data contracts are used as operation parameters and output values. If you want to use message contracts on proxy, thick Always generate message contracts when adding service reference in Visual studio. For svcutil use /mc switch.
精彩评论