This sample demonstrates how to expose an HTTP service that does not require client user authentication.
Prerequisites
If you haven't already done so, read the release notes document that explains how to sign up for a Windows Azure account and how to configure your environment.
Service
The service in this sample creates a simple RSS feed and returns it using the .NET Framework RSS/Atom features and the extended "Web-Style" service support.
Client
The client calls the syndication service and writes the feed contents to the console. The program first prompts for the service namespace to which to connect:
C# | |
---|---|
static void Main(string[] args) { Console.Write("Enter the name of the Service Namespace you want to connect to: "); string serviceNamespace = Console.ReadLine(); |
The client then transmits a request to the URI of the service.
C# | |
---|---|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceUri.ToString()); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream stream = response.GetResponseStream(); XmlReader reader = XmlReader.Create(stream); Rss20FeedFormatter formatter = new Rss20FeedFormatter(); formatter.ReadFrom(reader); Console.WriteLine("\nThese are the contents of your feed: "); Console.WriteLine(" "); Console.WriteLine(formatter.Feed.Title.Text); foreach (SyndicationItem item in formatter.Feed.Items) { Console.WriteLine(item.Title.Text + ": " + item.Summary.Text); } |
In the service configuration file, the
relayClientAuthenticationType
setting controls whether or not a client
is required to authenticate when accessing the HTTP service. The setting in this example is
None, which means that access is granted to anyone.
Xml | |
---|---|
<webHttpRelayBinding> <binding name="default"> <security relayClientAuthenticationType="None" /> </binding> </webHttpRelayBinding> |
Building and Running the Sample
First, build the solution in Visual Studio or from the command line. To run the application, do the following:
- From a command prompt, run the service (Service\bin\Debug\Service.exe).
- When prompted, type the service namespace, the issuer name (e.g. "owner") and
the issuer secret key with which you want the service to run. When
authorized, the service indicates that it is listening at the configured
address.
- From another command prompt, run the client (Client\bin\Debug\Client.exe).
- When prompted, type the issuer name (e.g. "owner"), the issuer secret key and the service namespace with which you want the client to
connect. Enter a line of text to send to the service, then press Enter.
- When finished, press Enter to exit the client and the service.
Note: |
---|
You can also point the Web browser to the HTTP URI given below to view the feed contents. |
Expected Output – Service
Your Service Namespace: <service-namespace> Your Issuer Name: owner Your Issuer Secret: <issuer-secret> Service address: http://<service-namespace>.servicebus.windows.net/services/SyndicationService/ Press [Enter] to exit |
Expected Output – Client
Enter the name of the Service Namespace you want to connect to: <service-namespace> These are the contents of your feed: Microsoft Windows Azure Feed Day 1: Today I woke up and went to work. It was fun. Day 2: Today I was sick. I didn't go to work. Instead I stayed home and wrote code all day. Day 3: This is my third entry. Using Microsoft Windows Azure is pretty cool! Press [Enter] to exit |
Did you find this information useful? Please send your suggestions and comments about the documentation.