How can I host a WCF service in Azure for both external and internal endpoints of a web role?

I am currently implementing WCF REST service on web roles in Windows Azure, and I'm trying to add some connection between role instances so that they can update each other when, say, some data is updated in the blob repository. What I would like to do is host the same WCF service on both the external and internal HTTP endpoints of the web role. However, from what I read, WCF is limited to one base address for each protocol when hosted in IIS. When I enable the internal HTTP endpoint for my role and try to start my service using WebServiceHostFactory, this is the error I get:

This collection already contains an address with an http scheme. You can have no more than one address for each circuit in this collection.

Parameter Name: item

I did a bit of work, and one workaround that I saw in different places suggests adding baseAddressPrefixFilter on the Internet. configurations. However, if I do not know the full URL for the endpoint before running the application, I am not sure how to do this.

Alternatively, this problem seems to be limited only to the IIS host, so is there any other hosting method that I could use in Azure that would work? I would think of self-service outside of any IIS context or that would not be reliable / secure enough, but I do not know for sure.

- , ? , , - -. WCF, - , . .

+3
1

, , . / , , , :

  • system.serviceModel web.config. , web.config, .
  • . ( HTTP), IIS, .
  • .svc . , , , .svc IIS, , .
  • factory. factory , , . , , . , , .
  • REST, WebServiceHost, , ServiceHost WebHttpBinding WebHttpBehavior .
  • , , :

using (new OperationContextScope((IContextChannel)myClientFromChannelFactory))
{
    myClientFromChannelFactory.MyServiceMethod();
}

MSDN Windows Azure , .

, - , .

0

Source: https://habr.com/ru/post/1730104/


All Articles