RedCritter - Calling WCF Services by atuullshahh

VIEWS: 6 PAGES: 4

More Info
									 Developer’s Guide

 Calling WCF Services




www.redcritter.com
Calling WCF Services

Use WCF Service calls in your RedCritter App
RedCritter supports WCF Service calls, however there are some special considerations for
cross-domain access, selecting protocols and creating WCF bindings which you must take
into account.



What’s different about calling WCF Services from RedCritter Apps?

Calling a WCF Service from a RedCritter App requires a few more steps than a traditional Silverlight
application.

1) Your RedCritter App always runs in the RedCritter server’s domain. This means all WCF calls that you
make to your own or 3rd party servers must be enabled through a cross-domain policy file. If the WCF
service that you would like to call does not have a cross-domain policy then you will need to create a
gateway service of your own to accept your call and retrieve data from the destination server.

2) In order to avoid “Mixed Content” warnings you should determine if the user is connected via HTTP
or HTTPS to their RedCritter Server and use the same protocol for your WCF Service calls if possible. The
IsHTTPS() method can be used to determine the current protocol.




3) When you add a WCF Service reference to your project the WCF Binding is created in your App’s
ServiceReferences.ClientConfig file. While this is fine for testing your RedCritter App locally, when you
deploy your App, RedCritter does not include this file. This means you will need to create your WCF
Bindings in code. It is important that you do not rely on the ServiceReferences.ClientConfig file for any
reason in your deployed App.




                                                                                                 www.redcritter.com
WCF Binding examples

In order to help you get started we have included examples for the most common WCF scenarios. Before
you begin creating your bindings with code be sure to add the following namespaces to your code file.




The next two examples demonstrate how to call a WCF Service using the HTTP and HTTPS protocols.
Ideally, if the WCF Service you are calling has methods for both the HTTP and HTTPS protocol, your App
should build its binding using the same protocol. This will eliminate “Mixed Content” warnings.

This following example demonstrates how to call a WCF Service using HTTP protocol.




This following example demonstrates how to call a WCF Service using HTTPS protocol.




                                                                                             www.redcritter.com
The next two examples demonstrate how to call a WCF Service using HTTP and HTTPS protocols and binary
encoding. Ideally, if the WCF Service you are calling has methods for both the HTTP and HTTPS protocol,
your App should build its binding using the same protocol. This will eliminate “Mixed Content” warnings.

The following example demonstrates how to call a WCF Service using the HTTP protocol along with binary
message encoding.




The following example demonstrates how to call a WCF Service using the HTTPS protocol along with binary
message encoding.




NOTE: After adding a WCF Service Reference to your project it can be very helpful to view the content of
your ServiceReferences.ClientConfig file when creating the code-behind binding from code only.



We hope you have enjoyed learning how to call WCF Services!

- The RedCritter




                                                                                              www.redcritter.com

								
To top