通过WCF服务公开合同

时间:2014-02-23 21:24:45

标签: .net wcf wcf-binding

如何通过互联网公开自托管 .Net WCF服务的运营合同?

我正在使用basichttpbinding和wshttpbinding。


扩展编辑问题:

我的app.config文件中有这个(请参阅编辑),但是对于其他外部服务如何知道要连接到哪个端点地址感到困惑? * 没有将它们放入浏览器并查看通过我的Web服务公开的操作合同的URL。 *

我不是必须在端点地址=“”中加入网址吗?如果我自己托管服务(意味着没有在IIS中实现它不需要),那么我将把外部服务的url放在哪里看?

请详细解释清楚这一点......

<system.serviceModel>
    <client />
    <services>
      <service name="Ryder.ShopProcessService.SOA.ShopProcessService">
        <!--<endpoint address="" binding="wsHttpBinding" contract="Ryder.ShopProcessService.SOA.IShopProcessService" bindingConfiguration="WsHttpBinding_IShopProcessService">
          <identity>
            <servicePrincipalName value="host/CNU348CHGD.corp.ryder.com" />
          </identity>
        </endpoint>-->
        <endpoint address="" binding="basicHttpBinding" contract="Ryder.ShopProcessService.SOA.IShopProcessService" bindingConfiguration="BasicHttpBinding_IShopProcessService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost/HandHeldSOA/ShopProcessServiceSOA/ShopProcessService/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IShopProcessService" closeTimeout="00:02:00"
          openTimeout="00:02:00" receiveTimeout="24.20:31:23.6470000"
          sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" />
      </basicHttpBinding>
    </bindings>

1 个答案:

答案 0 :(得分:1)

无论托管如何,对于HTTP绑定,您可以将其添加到配置文件中,如下所示

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />

或代码

host.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex");