【发布时间】:2015-05-13 10:40:32
【问题描述】:
我的解决方案中有两个项目:
1. WCF 服务库
2。 MVC 项目 使用 WCF 服务的 Azure 免费网站。
在未部署时一切正常 (localhost),但是当我将 MVC 项目部署到 Azure 时,我不知道如何使用 MVC 项目中的 WCF 服务。
解决方案:
WCF 服务库项目应用配置:
<client>
<endpoint address="http://localhost:8080/UserWCF" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IUserService" contract="Fildela_WCF.IFildelaService"
name="WSHttpBinding_IUserService">
<identity>
<userPrincipalName value="REFT\filip" />
</identity>
</endpoint>
</client>
<services>
<service name="Fildela_WCF.FildelaService">
<endpoint address="UserWCF" binding="wsHttpBinding" contract="Fildela_WCF.IFildelaService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080" />
</baseAddresses>
</host>
</service>
</services>
MVC 项目网页配置:
<client>
<endpoint address="http://localhost:8080/UserWCF" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IFildelaService" contract="FildelaServiceReference.IFildelaService"
name="WSHttpBinding_IFildelaService">
<identity>
<userPrincipalName value="DEFAULT\Filip" />
</identity>
</endpoint>
</client>
我如何在本地主机上使用我的服务:
- 右键单击我的 MVC 项目中的 Service References 文件夹,然后单击“添加服务引用”。
- 点击discover,选择Services下弹出的localhost服务。
- 我现在可以访问驻留在我的 WCF 项目中的函数:ServiceClient1 test = new ServiceClient1(); Test.HelloWorld();
我尝试用我的 azure 网站替换 localhost 地址,但它不起作用,(mywebsite.azurewebsites.net)。
我是新手,所以请耐心等待。现在我的解决方案中有两个项目,当我发布我的 MVC 项目时,WCF 项目不会随发布一起提供,对吗? 那么当 Web 项目发布到 Azure 时,我应该如何使用 MVC 项目中的 WCF 项目呢?
我应该使用 Azure 服务总线吗?
我应该改用 cloudapp 吗?
怎么样?什么?为什么?
非常感谢
【问题讨论】:
标签: asp.net-mvc web-services wcf