Kishore Kumar
Kishore Kumar

Reputation: 12874

Stream instead of byte[] in wCF?

I am developing a WCF Service for Uploading a document, previously I was using byte[] and now the requirement has changed to use Stream

I am using an external WSDL file for the WCF.

I have changed the signature of my functions which used byte[] to Stream, but now when I create a Client, the Upload function asking the same input parameter as previous.

Can you please help me in this.

What wrong. I cannot change the WSDL file. My WSDL file is using base64Binary for byte[] and this is enough for Stream too.

Server Code:

public Response Upload(RequestClass req)
{

}

public RequestClass{
    HeaderClass Header;
    Stream content;
}

Code generated in Client:

public Response Upload(Header hdr, byte[] content);

Updated:

<xs:element name="UploadDocumentReqMsg">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" name="UploadDocumentContent" nillable="true" type="str:Stream"/>
      </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:element name="UploadDocumentReqHdr" nillable="true" type="tns:RequestHeader"/>

My request in WSDL, so for both byte[] and Stream, I was using Stream.

Upvotes: 2

Views: 3406

Answers (1)

Jocke
Jocke

Reputation: 2284

What do you mean that you cannot change the WSDL? You need the new WSDL file (with the new signature) to generate the client properly.

When using Stream and WCF there are some limitations regarding binding, here is a link about that: http://www.codeproject.com/Articles/36973/Stream-Operation-in-WCF

Cheers --Jocke

Upvotes: 1

Related Questions