WCF - Test - Client


WCF - Test - Client

Windows Communication Foundation (WCF) Test Client (WcfTestClient.exe) is a Graphical Interface debugging tool to enable WCF service users to pass some test values as input parameters to a service and receive a response back.

Steps to work with WCF Test Client :

  • Open the Test Client executable file from "C:\Program Files\Microsoft Visual Studio [version]\Common7\IDE". 
  • Double click on the file WcfTestClient.exe to start the process.
  • Right click on “My Service Projects” to add the URL of the service to test as follows :


  • WCF service is launched in the Test client tool as shown below :

    The methods exposed by the service are listed with its interface name on the left pane.
    The Request tab on the right side of the tool takes the input parameters in the form of parameter name, value and data type.
    Click “Invoke” button to fetch results after providing valid inputs.
    The Response tab shows the result in the same format as Output parameter name, value and data type. 
  • The above process is repeated with XML formatted request and response parameters as shown below :

    Methods exposed by the service are listed with its interface name on the left pane.
    The Request XML on the right side of the tool takes the input parameters in the form of XML elements.
    The Response tab shows the result in the XML format as Output parameter elements with resulted values. 
    Results can be switched over “Formatted” and “XML” tabs.

Sample Service Request :

<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
    <s:Header>
        <a:Action s:mustUnderstand="1">http://tempuri.org/IService1/GetDataUsingDataContract</a:Action>
        <a:MessageID>urn:uuid:a00f6ce1-dcbb-4e42-afba-9b4205571b1d</a:MessageID>
        <a:ReplyTo>
        <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
        </a:ReplyTo>
    </s:Header>
<s:Body>
    <GetDataUsingDataContract xmlns="http://tempuri.org/">
        <composite xmlns:d4p1="http://schemas.datacontract.org/2004/07/WikiTechy_WcfServiceLibrary" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <d4p1:BoolValue>true</d4p1:BoolValue>
            <d4p1:StringValue>WikiTechy</d4p1:StringValue>
        </composite>
    </GetDataUsingDataContract>
</s:Body>
</s:Envelope> 

Sample Service Response :

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"z="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <s:Header>
        <a:Action s:mustUnderstand="1" u:Id="_2">http://tempuri.org/IService1/GetDataUsingDataContractResponse</a:Action>
        <a:RelatesTo u:Id="_3">urn:uuid:230d2293-9f14-4703-8348-a740fdd21ddd</a:RelatesTo>
        <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
        <u:Timestamp u:Id="uuid-140e3a44-84b5-4b70-803c-d8ca1600854d-11">
            <u:Created>2016-05-07T13:23:48.389Z</u:Created>
            <u:Expires>2016-05-07T13:28:48.389Z</u:Expires>
        </u:Timestamp>
        <c:DerivedKeyToken u:Id="uuid-140e3a44-84b5-4b70-803c-d8ca1600854d-7" xmlns:c="http://schemas.xmlsoap.org/ws/2005/02/sc">
            <o:SecurityTokenReference>
                <o:Reference URI="urn:uuid:53c26593-6d35-46eb-90c1-32d7721f7f84" ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/sct" />
            </o:SecurityTokenReference>
            <c:Offset>0</c:Offset>
            <c:Length>24</c:Length>
            <c:Nonce>sseSgRKsauLTPXuAYcCPJA==</c:Nonce>
        </c:DerivedKeyToken>
        <c:DerivedKeyToken u:Id="uuid-140e3a44-84b5-4b70-803c-d8ca1600854d-8" xmlns:c="http://schemas.xmlsoap.org/ws/2005/02/sc">
            <o:SecurityTokenReference>
                <o:Reference URI="urn:uuid:53c26593-6d35-46eb-90c1-32d7721f7f84" ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/sct" />
            </o:SecurityTokenReference>
            <c:Nonce>wYNYrHO5/4jzi8yMwMhywA==</c:Nonce>
        </c:DerivedKeyToken>
        <e:ReferenceList xmlns:e="http://www.w3.org/2001/04/xmlenc#">
            <e:DataReference URI="#_1" />
            <e:DataReference URI="#_4" />
        </e:ReferenceList>
        <e:EncryptedData Id="_4" Type="http://www.w3.org/2001/04/xmlenc#Element" xmlns:e="http://www.w3.org/2001/04/xmlenc#">
        <e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" />
        <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
            <o:SecurityTokenReference>
                <o:Reference ValueType="http://schemas.xmlsoap.org/ws/2005/02/sc/dk" URI="#uuid-140e3a44-84b5-4b70-803c-d8ca1600854d-8" />
            </o:SecurityTokenReference>
        </KeyInfo>
        <e:CipherData>
            <e:CipherValue>C087AlCtuIH7mDQ1d9ns2Bg/4syXXeT3JrS+ygH4VoT03ZzRJfVdvA1yoGRhjtPnp0eZ/JPyf3Mz1K7btNWY +jFGlX1MNWJdBPK7ptnHHUE3wo/NhPjjXOqgY0LhxPSeHsp7qdYSF70okL6EZ/06hpGBYzNM/</e:CipherValue>
        </e:CipherData>
        </e:EncryptedData>
        </o:Security>
    </s:Header>
    <s:Body u:Id="_0">
        <GetDataUsingDataContractResponse xmlns="http://tempuri.org/">
        <GetDataUsingDataContractResult xmlns:a="http://schemas.datacontract.org/2004/07/WikiTechy_WcfServiceLibrary" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
            <a:BoolValue>true</a:BoolValue>
            <a:StringValue>WikiTechySuffix</a:StringValue>
        </GetDataUsingDataContractResult>
        </GetDataUsingDataContractResponse>
    </s:Body>
</s:Envelope>