wcf restful service is not working after adding it to windows azure project.

Jun 30 2010 9:49 AM

I developed a simple calculator restful service using wcf, which works just fine when i run the service in visual studio environment and hit the corresponding rest-enabled url (i.e http://localhost:61854/Service1.svc/Calc/add/2/3) in IE.
But when i add this serivce to a azure project and run the solution in azure dev fabric, It does not work. Url that i am Using in this case is
http://127.0.0.1:81/Service1.svc/text/Calc/add/2/3.
I get following error
http://www.freeimagehosting.net/image.php?cb5172ac89.png
I suspect this error is because request is getting forwarded to http://127.0.0.1:5100/Service1.svc/text/Calc/add/2/3 automatically.
Has anyone faced similar issue while working with azure.
Do we need to make any change in configuration of wcf service for using it in azure solution. Here is my code
Contract
[ServiceContract]
    public interface IService1
   
{
        [OperationContract]
        [WebGet(UriTemplate="/Calc/{operation}/{op1}/{op2}", ResponseFormat=WebMessageFormat.Xml)]
        int Calc(string  operation, string op1,string op2);
    }

Implementation
public class Service1 : IService1
    {
        public int Calc(string  operation, string op1,string op2)
        {
            int result = 0;
            int a = Convert.ToInt32(op1);
            int b = Convert.ToInt32(op2);
            switch (operation)
            {
                case "add":
                    result = a + b;
                    break;
                case "sub":
                    result = a - b;
                    break;
                case "multi":
                    result = a * b;
                    break;
                case "div":
                    result = a / b;
                    break;
            }
            return result;
        }
    }


service model section from web.config
<system.serviceModel>
  <bindings>
   <webHttpBinding>
    <binding name="secure">
     <security mode="Transport">
      <transport/>
     </security>
    </binding>
   </webHttpBinding>
  </bindings>
  <services>
   <service name="TestSaveService.Service1">
    <endpoint contract="TestSaveService.IService1" behaviorConfiguration="RESTBehavior" binding="webHttpBinding"/></service>
  </services>
  <behaviors>
   <endpointBehaviors>
    <behavior name="RESTBehavior">
     <webHttp/>
    </behavior>
   </endpointBehaviors>
                  </behaviors>
</system.serviceModel>

 
 
 
 

Attachment: CloudService2.zip