2010-12-16 99 views
0

我曾经为我的常规WCF服务重写CreateServiceHost并在那里修改端点(动态添加一些方法)。现在转向Azure,并且拥有WCF服务Web角色,myServiceHost.Description.Endpoints是空的(我猜这是正常的,因为整个事情都可以正常工作)。但是,如果没有可用的端点,我怎么能修改端点?我可以在Azure WCF服务Web角色中访问ServiceEndpoint吗?

安德烈

// I can access this in Azure WCF Service Web Role 
RoleInstanceEndpoint azureEndpoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Endpoint1"]; 
// but I need something like this (to modify it, as I used to do in plain WCF) 
ServiceEndpoint usualEndpoint = myServiceHost.Description.Endpoints[0]; 

PS我可以开口后进行修改:

myServiceHost.Opened += AfterOpened; 

然后

public static void AfterOpened(object sender, EventArgs e) 
{ 
    ServiceHost myServiceHost = sender as ServiceHost; 
    ServiceEndpoint usualEndpoint = sh.Description.Endpoints[0]; 

但这种方式的呼叫动态地生成的方法最终会与一个错误如下:“带有动作'http://tempuri.org/ITestWCFService/Ping'的消息不能被处理d由于EndpointDispatcher中的ContractFilter不匹配而在接收方处发生。这可能是因为合同不匹配(发件人和收件人之间的操作不匹配)或发件人和收件人之间的绑定/安全性不匹配。检查发件人和收件人是否具有相同的合同和相同的绑定(包括安全要求,例如消息,传输,无)。“

回答

0

好的,解决方案是在Web.config中显式定义端点,以便我们可以捕获它早enogh,看详情here

相关问题