Can ASP.NET Web API be used to communicate with Service Bus for exhanging messages or what are the possibilities of ASP.NET Web API and Service Bus together.
Thanks in advance.
"Please MarkAsAnswer" if this reply answered your question.
Yes for sure, we can easliy use ASP.NET Web API to consume Service bus for that you need to create channel inside model under .cs file and consume the operation contracts on Controller side by simplying through that channel . Please find below code to create
channel using binging and endpoint .
public static
IMPNCustomerServiceChannel CreateChannel()
{
Uri serviceUri = ServiceBusEnvironment.CreateServiceUri("sb",
"mpncrm",
"CustomerService");
rishialagesa...
Participant
789 Points
179 Posts
ASP.NET WebAPI to use ServiceBus
Oct 29, 2012 01:59 PM|LINK
Can ASP.NET Web API be used to communicate with Service Bus for exhanging messages or what are the possibilities of ASP.NET Web API and Service Bus together.
Thanks in advance.
vvs1024
Member
2 Points
1 Post
Re: ASP.NET WebAPI to use ServiceBus
Nov 26, 2012 10:41 PM|LINK
Yes, if you host webservice yourself.
Reference this blog and source code here:
http://pfelix.wordpress.com/2012/03/15/asp-net-web-api-creating-an-host-using-azure-service-bus/
Amit Pachaha...
Member
154 Points
55 Posts
Re: ASP.NET WebAPI to use ServiceBus
Nov 27, 2012 06:35 AM|LINK
Yes for sure, we can easliy use ASP.NET Web API to consume Service bus for that you need to create channel inside model under .cs file and consume the operation contracts on Controller side by simplying through that channel . Please find below code to create channel using binging and endpoint .
public static IMPNCustomerServiceChannel CreateChannel()
{
Uri serviceUri = ServiceBusEnvironment.CreateServiceUri("sb", "mpncrm", "CustomerService");
ChannelFactory<IMPNCustomerServiceChannel> channelFactory =new ChannelFactory
<IMPNCustomerServiceChannel>("RelayEndpoint", new EndpointAddress(serviceUri));
IMPNCustomerServiceChannel channel = channelFactory.CreateChannel();
return channel;
}
Please mark it as answer if it works for you .
Ankit Purani...
Member
334 Points
65 Posts
Re: ASP.NET WebAPI to use ServiceBus
Dec 13, 2012 08:17 AM|LINK
ASP.NET Web API can indeed communicate with the Azure Service Bus. There can be number of possibilities in the question you asked:
1) The Web API is hosted "On Premise" and some Azure hosted cloud service wants to access this Web API using service bus.
2) The Web API is hosted on Azure and it wants to access some service which is hosted "On Premise" via Service Bus.
So which scenario you looking the solution for?
One thing is obvious, that you have to do establish a channel for the communication between the Service Bus and the Web API.
Let me know the scenario better so that I can provide you the exact solution.
Ankit
My .NET Blog
(Please Mark As Answer, if this helps you)