为我的Azure网站托管WCF服务

时间:2015-03-11 14:58:49

标签: asp.net-mvc web-services wcf

我的解决方案中有两个项目:

1。 WCF服务库

2。 MVC项目 Azure免费网站,它使用WCF服务。

一切都在未部署时工作(localhost),但是当我部署我的MVC项目到Azure时,我不知道如何使用我的MVC项目中的WCF服务。

解决方案:

My solution

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>

我如何在localhost上使用我的服务:

  1. 右键单击我的MVC项目中的Service References文件夹,然后单击“添加服务引用”。
  2. 单击“发现”并选择“服务”下弹出的本地主机服务。
  3. 我现在可以访问驻留在我的WCF项目中的函数:ServiceClient1 test = new ServiceClient1(); Test.HelloWorld();
  4. 我曾尝试用我的azure网站替换localhost地址,但它不起作用,(mywebsite.azurewebsites.net)。

    我是全新的,所以请耐心等待。我现在在我的解决方案中有两个项目,当我发布我的MVC项目时,WCF项目不会附带发布,对吗? 那么当Web项目发布到Azure时,我应该如何使用我的MVC项目中的WCF项目?

    我应该使用Azure Service Bus吗?

    我应该选择使用cloudapp吗?

    如何?什么?为什么呢?

    非常感谢

1 个答案:

答案 0 :(得分:0)

我决定将我的Azure网站项目转换为cloudapp项目。仅仅因为WCF服务而发布两个单独的Azure网站效率不高。

相关问题