Tuesday, January 20, 2009

Hosting WCF Service On Windows Azure.

 

Here are steps we need to perform in order  to host WCF service in Windows Azure platform.

1) Create a new Azure web cloud solution  project.

2) Add WCF service Template to the project.

3) Define the Service Contract with one or more Operation contract.

4) Create the Client application  which consumes the WCF service which is hosted on Azure platform.  In this step we are not going to  generate Metadata from WCF service instead  I am going to show you the magic how we can Invoke WCF service with out adding service meta data reference .

 

Step1 : Create Web Cloud Service project .

image

Now right click on SreeniWCFCloudService_WebRole project and add WCF Service template .

image

Define the Service Contract and add few Operation Contract as shown

image

Implement the above service contract as shown

image 

 

image

Once you see this above screen you have Successfully hosted the service.

 

image

Now let's create the WCF client which consumes the WCF Service  hosted in  Windows Azure.

here WCF hosted in Development Fabric .

 

Create the Console Application  copy the WCF Service Contract class file to create a proxy .

image

 

image

 

Here we can see the log information which is logged in Azure Service when we call WCF Operation from client  .

First Two Operations are (Add, SayHi) are success. but  Div Operation Failed with Divide by Zero Exception .

image .

 

Thanks

SreenivasaRagavan.

2 comments:

Unknown said...

Hi,

This is not a comment about your article. I was trying to do the same. I have developed a webrole as WCF Service. I had a problem in accessing the WCF Service from the client applications. Once you start the cloud service (not the web role), The IE will open up as you showed in your diagram(WCFServiceOnAzure Service - http://127.0.0.1:81/WCFServiceOnAzure.svc). Used the Svcutil(http://127.0.0.1:81/WCFServiceOnAzure.svc?wsdl) to generate the proxy to use it in the client. It was failed to generate the proxy.since inside the WSDL its importing namespace http://machinename.companyname.com:5100/WCFServiceOnAzure.svc?wsdl, s its saying couldn't resolve this.

What could be the problem here?

Thanks
Deepa

Sreeni.NET said...

Hi Deepa

when you are creating a Proxy using SvcUtil.exe it generate output.config file and Reference.cs (vb) see the A-Address part ...inside config

Here one one more way to test the service browse your Svc and get that Address (from IE )
try from WCFTestClient from VS.NET 2008 prompt( good way to test before accssing from Client App).
Nandri
Sreenivasaragavan