0

WCF novice here. In my solution i have 3 projects:

  1. Common Logic
  2. Client
  3. Server

Both Client and Server imports Common Logic.

My server has a method called GetNextFile. Here the interface implementation:

[OperationContract]
RemoteFileInfo GetNextFile(GUIDSetting GUID);

Here what RemoteFileInfo and GUIDSetting looks like:

[MessageContract]
public class GUIDSetting
{
    [MessageBodyMember]
    public string Guid;
}

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

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

    [MessageHeader(MustUnderstand = true)]
    public string Status;

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

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

And here a snippet of the actual implementation:

public RemoteFileInfo GetNextFile(GUIDSetting GUIDRequested)
{
    //stuff
    return result;
}

When i use svcutil to generate my proxy i use this parameters:

svcutil.exe /language:cs /out:generatedProxy.cs /config:app.config http://localhost:8001/MyService/

but that GetNextFile method in generated proxy looks like this:

public string GetNextFile(string Guid, out long Length, out string Status, out System.IO.Stream FileByteStream)
{
    //stuff
}

and this is the generated Async method:

[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
System.Threading.Tasks.Task<RemoteFileInfo> IServiceFileStream.GetNextFileAsync(GUIDSetting request)
{
    return base.Channel.GetNextFileAsync(request);
}

Why is this happening? I can try to figure out why I have Lenght, Status and Stream as out parameters, but where is fileName? And why the Async method have correct parameters (RemoteFileInfo and GUIDSetting)? I need those parameters on my sync function but I have no idea how to achieve it and why svcutils.exe gives me this output

HypeZ
  • 4,017
  • 3
  • 19
  • 34
  • well, this is one of those situation when the comment is actually a solution, it worked! If you post it as a answer I can mark it as solution! Thank you, i really need to study WCF to better understand this – HypeZ May 14 '14 at 08:28

1 Answers1

0

If you don't specifically need to control how the SOAP structure is composed, then try to use DataContract instead of MessageContract.

For example:

[DataContract]
public class GUIDSetting
{
    [DataMember]
    public string Guid;
}
Jon Lindeheim
  • 582
  • 4
  • 10