작업자 역할 내에서 Azure에 외부 대면 WCF 서비스를 호스팅하려고합니다.Azure 작업자 역할의 외부 HTTP 끝점은 가능합니까?
저는 로컬에서 아주 좋은 솔루션을 가지고 있습니다. 그러나 Azure에 게시하려고 시도 할 때 초기화/바쁜/중지 된 루프가됩니다.
는 내가 인터넷의 주위에 발견 한 정보는 다른 일을 말한다:
다른 소스가 가능하다고 말하지만, 그렇게하지 (불가능)
http://code.msdn.microsoft.com/WCF-Azure-Worker-Role-on-b394df49 (해킹으로 가능)
http://www.theworkflowelement.com/2011/01/worker-role-service-hosting-faq.html 두 명 이상의 링크를 게시 할 담당자를 확보하십시오.
게시하려고 할 때 마지막으로 중단됩니다.
누구든지이 작업을 수행하는 방법을 알고 있습니까, 아니면 실제로 불가능합니까? worker 역할로 호스팅하는 것은 매우 좋을 것이므로 웹 역할이 수반하는 svc 및 web.config 엉망을 사용하지 않아도됩니다.
이
내가 사용하고있는 코드입니다 : 이것은 전적으로 가능하다[ServiceContract(Namespace = "")]
public interface IMyService
{
[OperationContract]
[WebGet]
string Echo(string s);
}
public class MyService : IMyService
{
public string Echo(string s)
{
return "hey " + s;
}
}
public class TestPasswordValidator : UserNamePasswordValidator
{
public override void Validate(string userName, string password)
{
}
}
private static void StartService()
{
var endpoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["HttpsEndpoint"];
var uri = new Uri(endpoint.Protocol + "://" + endpoint.IPEndpoint + "/myservice");
var host = new ServiceHost(typeof(MyService), uri);
host.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = UserNamePasswordValidationMode.Custom;
host.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = new TestPasswordValidator();
var mexBehavior = new ServiceMetadataBehavior();
mexBehavior.HttpsGetEnabled = true;
mexBehavior.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
host.Description.Behaviors.Add(mexBehavior);
var soapBinding = new WSHttpBinding(SecurityMode.TransportWithMessageCredential);
soapBinding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
host.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, MetadataExchangeBindings.CreateMexHttpsBinding(), "mex");
host.AddServiceEndpoint(typeof(IMyService), soapBinding, "Soap");
var restBinding = new WebHttpBinding(WebHttpSecurityMode.Transport);
restBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
var restEndpoint = host.AddServiceEndpoint(typeof(IMyService), restBinding, "");
restEndpoint.Behaviors.Add(new WebHttpBehavior { HelpEnabled = true, DefaultOutgoingResponseFormat = WebMessageFormat.Json, AutomaticFormatSelectionEnabled = true, DefaultBodyStyle = WebMessageBodyStyle.WrappedRequest });
host.Open();
}
public override void Run()
{
StartService();
while (true)
{
Thread.Sleep(10000);
}
}
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
return base.OnStart();
}
메시지 : HTTP에서 URL http : // + : 20000/myservice /를 (를) 등록 할 수 없습니다. 프로세스에이 네임 스페이스에 대한 액세스 권한이 없습니다. 내가 추가하는 경우 restBinding.HostNameComparisonMode = HostNameComparisonMode.Exact; 실행 중이지만 연결할 수 없습니다. – biffen