2012-07-17 111 views
2

我已经花了很长时间把我的头撞在了墙上。WCF命名管道和Azure Web角色

运行Azure SDK 1.7/Visual Studio 2010 Ultimate。我似乎无法在IIS/WAS托管的命名管道上运行WCF服务。任何试图连接到我的服务在计算模拟器产生

管端点“net.pipe://localhost/services/MyService.svc”无法在本地计算机

我上找到将发布我的代码,但事实证明,这篇文章http://blogs.msdn.com/b/tomholl/archive/2011/06/28/hosting-services-with-was-and-iis-on-windows-azure.aspx的示例代码给了我完全相同的错误。所有的代码都可以在该网站上找到。

据我所知,powershell任务正在成功执行。 (好吧,我必须在启动任务中将ExecutionPolicy从Unrestricted更改为RemoteSigned,但之后它运行得很好。)NetPipeActivator服务正在运行,当我调用Get-WebApplication时,我在协议中看到net.pipe列表:

PS C:\> $WebRoleSite = (get-website "*webrole*").Name 
PS C:\> Get-WebApplication -Site $WebRoleSite 

Name    Application pool Protocols Physical Path 
----    ---------------- --------- ------------- 
WcfService1  4a16b147-f9ac-41d9 http,net.pip c:\Code\WasInAzure\WcfService1 
       -9543-0577da64fb9a e 

还能发生什么?

+0

检查那些线程帮助: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/3a97c32d-07f1-40a9-ab8c-f1220c8feb76 的http://社会.msdn.microsoft。COM /论坛/ EN-US/WCF /线程/ 55fae194-e1ea-4bd0-8c0a-dd924d4d4ac8 – 2012-07-18 11:15:44

回答

1

我解决了它。唷!

我的问题是我从根网站托管我的WCF服务,而不是子应用程序。我必须添加以下行到powershell脚本以启用主网站上的命名管道:

Set-ItemProperty "IIS:/Sites/$WebRoleSite" -Name EnabledProtocols 'http,net.pipe' 
1

我也在处理此示例代码时遇到了此错误。就我而言,我在尝试复制Cloud Service时收到错误,但未收到解决方案中的原始Cloud Service项目。

最终的关键区别是ServiceConfiguration.csfg file中ServiceConfiguration元素的osFamily属性。

在示例中,它被设置为 “2:”

<ServiceConfiguration serviceName="WasInAzure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="2" osVersion="*" schemaVersion="2015-04.2.6"> 

在新的项目中,它被设置为 “4:”

<ServiceConfiguration serviceName="WasInAzure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="*" schemaVersion="2015-04.2.6"> 

在OS的变化打破了PowerShell脚本。下面是RoleStart.ps1的更新版本,它应该服务器2012 R2(osFamily 4)上工作:改变

write-host "Begin RoleStart.ps1" 
import-module WebAdministration 

# Starting the listener service 
install-windowsfeature -name AS-Named-Pipes 
$listenerService = Get-WmiObject win32_service -filter "name='NetPipeActivator'" 
$listenerService.ChangeStartMode("Manual") 
$listenerService.StartService() 

# Enable net.pipe bindings 
$WebRoleSite = (Get-WebSite "*webrole*").Name 
Get-WebApplication -Site $WebRoleSite | Foreach-Object { $site = "IIS:/Sites/$WebRoleSite" + $_.path; Set-ItemProperty $site -Name enabledProtocols 'http,net.pipe'} 
New-ItemProperty "IIS:/Sites/$WebRoleSite" -name bindings -value @{protocol="net.pipe";bindingInformation="*"} 

write-host "End RoleStart.ps1" 

摘要:

  • 新增install-windowsfeature -name AS-NamedPipes,作为NetPipesActivator服务不存在。

  • 更新EnabledProtocolsenabledProtocols。那个人进行了一些搜索。我终于找到了a comment to a blog post,这使我走上了正确的道路。