简体   繁体   中英

WCF Client Syntax is different from Service syntax when using MessageContract

I have a service which uses MessageContract

The syntax changes in client side. I don't know why. I am using Visual studio 2010 and target framework is 4.0

Here is my MessageContract :

[MessageContract]
public class DownloadRequest
{
    [MessageBodyMember]
    public string FileName;
}

[MessageContract]
   public class RemoteFileInfo : IDisposable
{
    [MessageHeader(MustUnderstand = true)]
    public string FileName;

    [MessageHeader(MustUnderstand = true)]
    public long Length;

    [MessageBodyMember(Order = 1)]
    public System.IO.Stream FileByteStream;

    public void Dispose()
    {
        if (FileByteStream != null)
        {
            FileByteStream.Close();
            FileByteStream = null;
        }
    }
}

My service Contract has this :

[OperationContract]
        RemoteFileInfo DownloadFile(DownloadRequest request);

And the implimentation is :

public RemoteFileInfo DownloadFile(DownloadRequest request)
{
    RemoteFileInfo result = new RemoteFileInfo();
      .........
      ....
    return result;

}

And I am geting following Error.

WCF客户端错误

Any Ideas ?

EDIT : I use basic http binding with streaming

from the error message, it seems you need to refresh the service reference again. in visual studio, click menu Project -> select 'Add Service Reference...'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM