none
How to access ServiceEndpoint instance for modification in WCF Service Web Role?

    Question

  • Hi,

    I wonder is this even possible, and if yes then how.

    In the plain WCF it's possible to override CreateServiceHost, take ServiceEndpoint instance from service host's Description.Endpoints array, and modify it as needed (in my case it's about adding some method dynamically, like here). But in Azure (WCF Service Web Role), yes I can override CreateServiceHost, and the Description.Endpoints array is there, but it's empty! The ServiceEndpoint instance appears only after Opened event of the service host, but then it's too late to modify it (in my case calling that dynamic method would fail, even if it showed up OK in the method list).

    Now what should I do to get access to the ServiceEndpoint instance early enough to modify it successfully?

    Thank you! /Andres

     

    Thursday, December 16, 2010 5:59 PM

Answers

  • Hi,

    Did you define the service endpoint explicitly in web.config? if you didn't define the endpints, you will not get any endpoints in CreateServiceHost, the default endpoint would be added in the post process.

    Define endpoint explicitly may solve your problem.

        <services>
          <service name="WebRole1.Service1">
            <endpoint address="b1" contract="WebRole1.IService1" binding="basicHttpBinding" bindingConfiguration="conf" />
          </service>
        </services>

    Thanks,


    Mog Liang
    • Marked as answer by Andres24 Friday, December 17, 2010 8:53 AM
    Friday, December 17, 2010 7:25 AM

All replies

  • Hi,

    Did you define the service endpoint explicitly in web.config? if you didn't define the endpints, you will not get any endpoints in CreateServiceHost, the default endpoint would be added in the post process.

    Define endpoint explicitly may solve your problem.

        <services>
          <service name="WebRole1.Service1">
            <endpoint address="b1" contract="WebRole1.IService1" binding="basicHttpBinding" bindingConfiguration="conf" />
          </service>
        </services>

    Thanks,


    Mog Liang
    • Marked as answer by Andres24 Friday, December 17, 2010 8:53 AM
    Friday, December 17, 2010 7:25 AM
  • Hi,

    Yes, this helped, thank you very much!
    Got it working by adding the block below to the system.serviceModel:

        <services>
          <service name="MyWcfServiceWebRole.MyService">
            <endpoint binding="basicHttpBinding" contract="MyWcfServiceWebRole.IMyService">
            </endpoint>
          </service>
        </services>

    Andres

    Friday, December 17, 2010 8:54 AM