Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are 3 basic ways to create a WCF client:</p> <ol> <li><p>Let Visual Studio generate your proxy. This auto generates code that connects to the service by reading the WSDL. If the service changes for any reason you have to regenerate it. The big advantage of this is that it is easy to set up - VS has a wizard and it's all automatic. The disadvantage is that you're relying on VS to do all the hard work for you, and so you lose control.</p></li> <li><p>Use <code>ChannelFactory</code> with a known interface. This relies on you having local interfaces that describe the service (the service contract). The big advantage is that can manage change much more easily - you still have to recompile and fix changes, but now you're not regenerating code, you're referencing the new interfaces. Commonly this is used when you control both server and client as both can be much more easily mocked for unit testing. However the interfaces can be written for any service, even REST ones - take a look at <a href="http://vertigotwitter.codeplex.com/Wikipage" rel="nofollow noreferrer">this Twitter API</a>.</p></li> <li><p>Write your own proxy - this is fairly easy to do, especially for REST services, using the <code>HttpClient</code> or <code>WebClient</code>. This gives you the most fine grain control, but at the cost of lots of service API being in strings. For instance: <code>var content = new HttpClient().Get("http://yoursite.com/resource/id").Content;</code> - if the details of the API change you won't encounter an error until runtime.</p></li> </ol> <p>Personally I've never liked option 1 - relying on the auto generated code is messy and loses too much control. Plus it often creates serialisation issues - I end up with two identical classes (one in the server code, one auto generated) which can be tided up but is a pain.</p> <p>Option 2 should be perfect, but Channels are a little too limiting - for instance they <a href="https://stackoverflow.com/questions/2516914/getting-error-detail-from-wcf-rest">completely lose the content of HTTP errors</a>. That said having interfaces that describe the service is much easier to code with and maintain.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload