为我的 Azure 网站托管 WCF 服务
Host a WCF service for my Azure Website
我的解决方案中有两个项目:
1. WCF 服务库
2。 MVC项目使用WCF服务的Azure免费网站
在未部署时一切正常,(localhost),但是当我 部署 我的 MVC 项目时,我不知道如何从我的 MVC 项目使用我的 WCF 服务到 Azure。
解法:
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 项目 Web 配置:
<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 文件夹,然后单击 "Add Service Reference"。
- 单击“发现”并select 服务下弹出的本地主机服务。
- 我现在可以访问驻留在我的 WCF 项目中的函数:ServiceClient1 test = new ServiceClient1();
Test.HelloWorld();
我已尝试用我的 Azure 网站替换本地主机地址,但它不起作用,(mywebsite.azurewebsites.net)。
我对此很陌生,请多多包涵。我现在的解决方案中有两个项目,当我发布 MVC 项目时,WCF 项目不会随发布一起发布,对吧?
那么当 Web 项目发布到 Azure 时,我应该如何使用我的 MVC 项目中的 WCF 项目?
我应该使用 Azure 服务总线吗?
我应该改用 cloudapp 吗?
怎么样?什么?为什么?
非常感谢
我决定将我的 Azure 网站项目转换为 cloudapp 项目。仅仅因为 WCF 服务而发布两个单独的 Azure 网站效率不高。
我的解决方案中有两个项目:
1. WCF 服务库
2。 MVC项目使用WCF服务的Azure免费网站
在未部署时一切正常,(localhost),但是当我 部署 我的 MVC 项目时,我不知道如何从我的 MVC 项目使用我的 WCF 服务到 Azure。
解法:
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 项目 Web 配置:
<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 文件夹,然后单击 "Add Service Reference"。
- 单击“发现”并select 服务下弹出的本地主机服务。
- 我现在可以访问驻留在我的 WCF 项目中的函数:ServiceClient1 test = new ServiceClient1(); Test.HelloWorld();
我已尝试用我的 Azure 网站替换本地主机地址,但它不起作用,(mywebsite.azurewebsites.net)。
我对此很陌生,请多多包涵。我现在的解决方案中有两个项目,当我发布 MVC 项目时,WCF 项目不会随发布一起发布,对吧? 那么当 Web 项目发布到 Azure 时,我应该如何使用我的 MVC 项目中的 WCF 项目?
我应该使用 Azure 服务总线吗?
我应该改用 cloudapp 吗?
怎么样?什么?为什么?
非常感谢
我决定将我的 Azure 网站项目转换为 cloudapp 项目。仅仅因为 WCF 服务而发布两个单独的 Azure 网站效率不高。