Question

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

Was it helpful?

Solution

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;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top