0

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>
John Saunders
  • 160,644
  • 26
  • 247
  • 397
sagesky36
  • 4,542
  • 19
  • 82
  • 130
  • 1
    Have you ever heard of `mex`? Do you have a `mex` endpoint defined? That's "**me** tadata e **x** change" – John Saunders Feb 23 '14 at 21:26
  • John see "Expansion of Question for Edit:" in my question for some additional help... – sagesky36 Feb 24 '14 at 13:56
  • The URL in the endpoint declaration is a _relative_ URL. Try `http://localhost/HandHeldSOA/ShopProcessServiceSOA/ShopProcessService/mex`. – John Saunders Feb 24 '14 at 14:17
  • BTW, expansion of your question belongs in your _question_, not in an answer. I moved it to where it belongs. – John Saunders Feb 24 '14 at 14:18
  • John, I get your point about the endpoint declaration. Since this is a self-hosting service, I would assume I would eventually need to publish it to a specific machine. Once published there, the URL above would change to that machine name plus the rest of the suffix. However, I'm still confused as to what process is able to give external applications the ability to consume the contracts I have set up in this service. I mean, if it's hosted on IIS, you can go to a url and see the contracts for it. But if it's self-hosted, how can you expose the contracts to the outside world? – sagesky36 Feb 24 '14 at 18:25
  • The same exact way. I don't understand your confusion. The self-hosted service is hosted at a URL, right? A consumer of the metadata would use the base URL followed by /mex. That's all there is to it. – John Saunders Feb 24 '14 at 18:26

1 Answers1

1

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");
John Saunders
  • 160,644
  • 26
  • 247
  • 397
Milan Raval
  • 1,880
  • 1
  • 16
  • 33