Did you know that Visual Studio includes a WCF Test Client? No? It’s very useful for testing out various services, especially SOAP ones. RESTful services are much easier to test as you just need a browser, but SOAP requires some sort of client.
Browse to the following path (note, this is Visual Studio 2013, adjust the 12.0 to whatever version you have):
Once you’re there look for the icon shown in figure 1.
Now, while this is a useful tool, it’s so unintuitive, it’s not funny. One of the stumbling points has to do with Arrays so let’s look at this example.
Fun With Arrays
Connect to a service, and you’re given a tree-view of the methods that you can call on the service. So far, so good. If you click on a method, then you’re given the opportunity to add test values and then execute it to get the result. But wait, what do we have here? Our service takes an array of
ints, what’s this weird
length=0 stuff. Oh, of course we don’t have any items yet (Figure 02).
So let’s see here. What happens if we select the length. Hmmm, a drop-down, good… Awww, it’s a drop-down to null (Figure 03).
Hmm, ok. Well, I just want to pass a single
int anyway, what happens if I enter a
1 in the box. D’oh! Error. (Figure 04).
Ok, so that doesn’t work either. What am I to do to get this work? So intuitive, right!? Well, if you hadn’t guessed it, we need to change the text
length=1. Now we get a little arrow next to the Attribute name (Figure 05).
Now, if you expand out the attribute, you’ll see you have a place to enter your values. Sweet! (Figure 06)
I’m not the first one to stumble on this, and I’m sure I won’t be the last. I ended up finding other posts on the topic, but I figured another one on the web couldn’t hurt. Hopefully this saves you from banging your head against a wall the next time you use the “Ultra Intuitive” WCF Test Client.