Search code examples
visual-studiowcfwcftestclient

Debug WCF service in IIS with object as input


I want to debug a WCF service locally in Visual Studio. The called function looks like this:

public void PerformAction(Directory[] dirs) {
    ....
}

Directory is a class with some properties. In the WCF test client I want to test the function but how can I set the input values for the Directory array?


Solution

  • Taking the default WCF template as an example, I made the following definition.

    [OperationContract]
            //[WebGet(RequestFormat =WebMessageFormat.Json,ResponseFormat =WebMessageFormat.Json)]
            string GetData(CompositeType[] value);
    
            public string GetData(CompositeType[] value)
            {
                return string.Format("You entered: {0},{1}", value[0].StringValue,value[1].StringValue);
            }
    

    First enter the length of the array, then select the array type, and finally enter the values of the individual elements one by one.
    enter image description here
    Wish it is useful to you, feel free to let me know if there is anything I can help with.