简体   繁体   中英

Exposing contracts via a WCF service

How does one expose the Operation contracts of a self hosting .Net WCF service over the internet?

I'm using basichttpbinding and wshttpbinding.


Expansion of Question for Edit:

I do have that in my app.config file (see edit), but am confused as to how would another outside service know what endpoint address to connect to? * There is no url for them to put into a browser and see what operation contracts are exposed via my web service. *

Wouldn't I have to put a url inside the endpoint address="" ? If I'm self hosting the service (meaning not implemented in IIS which it doesn't need to be), where would I put the url for an outside service to see?

Please explain more to clear this up....

<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>

Regardless of hosting, for HTTP Binding you can add it in configuration file as below

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

or in code

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM