技术开发 频道

Azure Services探索:在Azure服务中增加WCF服务

  然后在myMessageLogger.svc.cs中实现这个Interface,具体的实现非常简单,就是向文件存储中写消息。

  之后我们需要检查和确认WCF的配置文件,并做一个的改动,将WSHttpBinding 修改成 BasicHttpBinding ,如下图:

 

  关于BasicHttpBinding和WSHttpBinding的差异,可以参见文章最后一些链接。除了性能,对WS-*的协议支持,Session/事务等支持的不同,Security Mode and the Client Credential Type in WCF文章中给出了不错的建议: If broad reach across platforms is your goal, there's no better choice today than using the WS-I basic profile over SSL which of course would also mean using basicHttpBinding instead of wsHttpBinding. It's important to note that this particular binding doesn't provide CIA by default.

  之后可以F5 启动我们的Azure 服务,然后访问WCF的地址http://localhost/myMessageLogger.svc,测试一下WCF服务是否能够正确地运行。

  然后我在我的开发环境就出现了下面这个错误页面:

 

  从这个界面可以发现一些有趣的现象,第一 , Azure 使用了另外一个端口 127.0.0.1:5100,第二,证明BasicHttpBinding的确默认没有带安全标示。

  看到左边的Detail Error Information感觉.svc 文件好像根本没有进程来Handler,感觉IIS7 用一个静态文件的进程在处理,思考了两分钟,头脑中闪现了WAS,然后去控制面板检查,发现果然WAS (Windows Process Activation Service)没有安装.

  然后退出Visual Studio 转为系统安装,我是运行在Windows Server 2008上,安装WAS的界面如下:

 

  安装之后,都不用重新启动,继续F5 运行,这下WCF服务可以访问了

 

  根据之前的设计,目前的任务已经完成了一半了,我们已经成功在一个Web Role中发布了一个记录消息的WCF服务,剩下的工作是要在Worker Role中调用这个WCF服务。

0
相关文章