Search code examples
wcfwsdlsvcutil.exe

WCF Proxy not being generated properly


I have a WCF Service that needs to return a file from a database. To that end, I have created two MessageContract classes, one for input and one for output. The code is as follows:

[MessageContract]
public class AttachmentFile
{
    [MessageHeader(MustUnderstand = true)]
    public Int32 AttachmentID;

    [MessageHeader]
    public String FileName;

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

    public AttachmentFile(Attachment att)
    {
        AttachmentID = (Int32)att.AttachmentID;
        FileName = att.FileName;
        Data = new MemoryStream(att.FileBytes);
    }
}

[MessageContract]
public class AttachmentFileID
{
    [MessageBodyMember]
    public Int32 AttachmentID;
}

public AttachmentFile GetAttachmentFile(AttachmentFileID AttachmentID)
{
}

The generated WSDL looks correct:

<wsdl:operation name="GetAttachmentFile">
    <soap12:operation soapAction="http://tempuri.org/IAttachments/GetAttachmentFile" style="document"/>
    <wsdl:input name="AttachmentFileID">
        <soap12:body use="literal"/>
    </wsdl:input>
    <wsdl:output name="AttachmentFile">
        <soap12:header message="i0:AttachmentFile_Headers" part="AttachmentID" use="literal"/>
        <soap12:header message="i0:AttachmentFile_Headers" part="FileName" use="literal"/>
        <soap12:body use="literal"/>
    </wsdl:output>
</wsdl:operation>

However, when I run svcutil.exe http://localhost:8002/IAttachments?wsdl, the generated code comes out as:

public string GetAttachmentFile(ref int AttachmentID, out System.IO.Stream Data)
{
    AttachmentFileID inValue = new AttachmentFileID();
    inValue.AttachmentID = AttachmentID;
    AttachmentFile retVal = ((IAttachments)(this)).GetAttachmentFile(inValue);
    AttachmentID = retVal.AttachmentID;
    Data = retVal.Data;
    return retVal.FileName;
}

I'm sure I'm missing something simple, but I can't seem to find what it is. Does anyone have any clues to what could be causing this?


Solution

  • Upon further examination of the code, the /messageContract switch fixed one of the calls only to screw up another one. However, using the /importXmlTypes switch fixed everything.