none
What kind of data format does WCF support when using TCP? RRS feed

  • Question

  • Hi Guys,

    I want to know which data format can the WCF support when using TCP or UDP?

    I know SOAP format is supported when using TCP in .NET Remoting, but not sure about WCF.

    Best regards,

    Roy Chow


    • Edited by Roy Chou Wednesday, February 7, 2018 2:41 AM
    Wednesday, February 7, 2018 2:40 AM

Answers

  • Hi Roy,

    >> So, when using TCP in WCF, we can use xml or json data format

    Since your original issue related with data format has been resolved, I would suggest you mark the helpful reply as answer to close this thread.

    >> using the default MessageFormatter, the Message Inspector give us the following xml

    For this new issue, I would suggest you post new threads, and share us the issue you got while implementing MessageFormatter.

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Roy Chou Saturday, February 24, 2018 1:23 AM
    Monday, February 12, 2018 5:55 AM

All replies

  • Hi Roy,

    What do you mean by data format?

    In general, SOAP is said to be a protocol specification for exchanging structed information, and XML and JSON are said to be data formats which is serialized while transferring the message.

    Both XML and JSON are supported when using TCP, SOAP is supported a protocol while suing WCF.

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, February 8, 2018 5:45 AM
  • Yes when mentioned SOAP I mean XML, sorry.

    So, when using TCP in WCF, we can use xml or json data format. Got you thanks!

    By using the default MessageFormatter, the Message Inspector give us the following xml. 

    1) I would like to know what that mean? They look like the SOAP protocol message. 

    2) Does that mean it's using SOAP protocol based on TCP?

    public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
            {
                Console.WriteLine("Message received:\n{0}", request.ToString());
                return null;
    
            }
    
            public void BeforeSendReply(ref Message reply, object correlationState)
            {
                Console.WriteLine("Message to reply:\n{0}", reply.ToString());
            }

     
    <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
      <s:Header>
        <a:Action s:mustUnderstand="1">http://tempuri.org/ICalculate/TestMethod</a:Action>
        <a:MessageID>urn:uuid:8368e58b-7524-46c8-b19a-91b6719a487a</a:MessageID>
        <a:ReplyTo>
          <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
        </a:ReplyTo>
        <VsDebuggerCausalityData xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPoyn65zYNeRdIrK84mRwwsSsAAAAAXMHYMcVtq0S/0GDYGUrnBh9IQGoP2NJMkMHo7FIaV1QACQAA</VsDebuggerCausalityData>
        <a:To s:mustUnderstand="1">net.tcp://localhost:3000/calcSvc</a:To>
      </s:Header>
      <s:Body>
        <TestMethod xmlns="http://tempuri.org/">
          <testDto xmlns:b="http://schemas.datacontract.org/2004/07/svcContract" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <b:TestID>6</b:TestID>
            <b:TestName>rzhou</b:TestName>
          </testDto>
        </TestMethod>
      </s:Body>
    </s:Envelope>

    Sunday, February 11, 2018 1:34 AM
  • Hi Roy,

    >> So, when using TCP in WCF, we can use xml or json data format

    Since your original issue related with data format has been resolved, I would suggest you mark the helpful reply as answer to close this thread.

    >> using the default MessageFormatter, the Message Inspector give us the following xml

    For this new issue, I would suggest you post new threads, and share us the issue you got while implementing MessageFormatter.

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Roy Chou Saturday, February 24, 2018 1:23 AM
    Monday, February 12, 2018 5:55 AM