Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
0
Answer
wcf restful service is not working after adding it to windows azure project.
sandesh shri
14y
2.2k
1
Reply
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
h
ttp://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
Post
Reset
Cancel
Answers (
0
)
Next Recommended Forum
How do you access the children of a WPF Canvas class?
Proxy authentication problem WPF browser app calling WCF service