wcfduplex-channel

General WCF Service setup for beginner


I'm generally looking for some kind of feedback on wcf service where I'm a complete beginner. Basically the client needs to transfer xml files and images to the service as well as be able to pull down datasets/or xml files from the service. I have set up a wsDualHttpBinding duplex contract to allow this(callbacks). My main three questions are:

  1. Is setting up a duplex contract the only way to achieve back/forth data transfer?
  2. With wsDualHttpBinding, I can't stream apparently, if my files are no bigger than 10mb, is that normal to let that buffer and then send it up to the service?
  3. What is the best way to send a .jpg image up to the service?

I really could use some feedback please, wcf can be very complex and finding the correct way of doing something isn't easy for a beginner. Havn't had much feedback from previous questions on this topic.

Edit: After setting up stream, getting error for endpoint not following http protocol

  <binding name="duplexendpointserver"
                maxReceivedMessageSize="2147483647"
                transferMode="Streamed"
                messageEncoding="Mtom">
      <security mode="TransportCredentialOnly">
        <message clientCredentialType="UserName" />
      </security>
    </binding>         <!--<reliableSession ordered="true" inactivityTimeout="00:10:00"/>-->
    <!--</binding>-->
  </basicHttpBinding>
</bindings>


<services>
  <service name="Votex.Service.WCFServices" behaviorConfiguration="svcbh">
    <endpoint name="duplexendpoint" address="" binding="basicHttpBinding" bindingConfiguration="duplexendpointserver" contract="Votex.Service.IWCFServices" ></endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>

Solution

  • Check out this MSDN article on Large Data and Streaming.

    1. You can set up a service to have methods that can send and receive without a duplex contract.
      • void Upload(Stream uploadStream)
      • Stream Download(string fileName))
    2. You can only use streams with the following bindings: BasicHttpBinding, NetTcpBinding, NetNamedPipeBinding, and WebHttpBinding.
    3. I would recommend you read the entire article I linked above and that should get you started.