none
how to test and expose Multiple endpoints in WCF RRS feed

  • Question

  • Hi

    I have tried to create multiple endpoint (with different address and binding but contract same) for my service Service1.

    I have given base address in host and relative address while endpoints are defined. Now I had tried to access my service in browser with these endpoint's address but only base address worked.

    Here I have few questions:

    1. How can I test multiple endpoints for same contract but different address and binding.

    2. When I update existing service reference then how would I consume these different endpoints.

    3. If I define mex endpoint then what will be the difference, how to test for succeed and how to consume.

    4. How would I consume my service using JQuery with mex endpoint.

    Thanks


    Rakesh Kumar

    Thursday, November 14, 2013 4:50 PM

Answers

  • Hi,

    I create example a self host WCF Service with different enpoint address but same contract.
    So for your first question,please try to check it:

    In the service configure file:

    <system.serviceModel>
        <services>
          <service name="WcfServiceLibrary1.Service1">
            <host>
              <baseAddresses>
                <add baseAddress = "http://localhost:8733/Service1/" />
              </baseAddresses>
            </host>
           
            <endpoint address="basicService1" binding="basicHttpBinding" contract="WcfServiceLibrary1.IService1">
              <identity>
                <dns value="localhost"/>
              </identity>
            </endpoint>
            <endpoint address="wsService1" binding="wsHttpBinding" contract="WcfServiceLibrary1.IService1"></endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    Then you can use the mex endpoint address to add service reference, in my example the mex address is:
    http://localhost:8733/Service1/mex


    Then after that in the client side:
      <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="BasicHttpBinding_IService1" />
                </basicHttpBinding>
                <wsHttpBinding>
                    <binding name="WSHttpBinding_IService1" />
                </wsHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://localhost:8733/Service1/basicService1" binding="basicHttpBinding"
                    bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
                    name="BasicHttpBinding_IService1" />
                <endpoint address="http://localhost:8733/Service1/wsService1" binding="wsHttpBinding"
                    bindingConfiguration="WSHttpBinding_IService1" contract="ServiceReference1.IService1"
                    name="WSHttpBinding_IService1">
                    <identity>
                        <userPrincipalName value="******" />
                    </identity>
                </endpoint>
            </client>
        </system.serviceModel>

    For your second question, you can just click the service reference, then right click update service reference, then use the right endpoint address according to the client configure file.

    For your third question, I have already defined the mex endpoint in the above example, it can work well.

    For your last question, please try to check the following blog:
    #How to call a WCF service from JQuery:
    http://blog.thomaslebrun.net/2011/11/jquery-calling-a-wcf-service-from-jquery/#.UoXBhiSwqM8 .

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, November 15, 2013 6:41 AM
    Moderator
  • Hi,

    If you want to create the wcf service without .svc extension, please try to check the following:
    #WCF Service on IIS. How to get rid of the “Service.svc” component in the URL path:
    http://stackoverflow.com/questions/11440562/wcf-service-on-iis-how-to-get-rid-of-the-service-svc-component-in-the-url-pat .

    #WCF removing .svc extention:
    http://stackoverflow.com/questions/7354616/wcf-removing-svc-extention .

    Or you can just use the httpGetUrl:

      <serviceMetadata httpGetEnabled="true" httpGetUrl=http://localhost:80/services/>

    Then you can use the httpGetUri address to get the wsdl, also the client can use this uri to call the wcf services.

    #ServiceMetadataBehavior.HttpGetUrl Property:
    http://msdn.microsoft.com/en-us/library/system.servicemodel.description.servicemetadatabehavior.httpgeturl(v=vs.110).aspx .

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, November 28, 2013 10:24 AM
    Moderator

All replies

  • Hi,

    I create example a self host WCF Service with different enpoint address but same contract.
    So for your first question,please try to check it:

    In the service configure file:

    <system.serviceModel>
        <services>
          <service name="WcfServiceLibrary1.Service1">
            <host>
              <baseAddresses>
                <add baseAddress = "http://localhost:8733/Service1/" />
              </baseAddresses>
            </host>
           
            <endpoint address="basicService1" binding="basicHttpBinding" contract="WcfServiceLibrary1.IService1">
              <identity>
                <dns value="localhost"/>
              </identity>
            </endpoint>
            <endpoint address="wsService1" binding="wsHttpBinding" contract="WcfServiceLibrary1.IService1"></endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    Then you can use the mex endpoint address to add service reference, in my example the mex address is:
    http://localhost:8733/Service1/mex


    Then after that in the client side:
      <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="BasicHttpBinding_IService1" />
                </basicHttpBinding>
                <wsHttpBinding>
                    <binding name="WSHttpBinding_IService1" />
                </wsHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://localhost:8733/Service1/basicService1" binding="basicHttpBinding"
                    bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
                    name="BasicHttpBinding_IService1" />
                <endpoint address="http://localhost:8733/Service1/wsService1" binding="wsHttpBinding"
                    bindingConfiguration="WSHttpBinding_IService1" contract="ServiceReference1.IService1"
                    name="WSHttpBinding_IService1">
                    <identity>
                        <userPrincipalName value="******" />
                    </identity>
                </endpoint>
            </client>
        </system.serviceModel>

    For your second question, you can just click the service reference, then right click update service reference, then use the right endpoint address according to the client configure file.

    For your third question, I have already defined the mex endpoint in the above example, it can work well.

    For your last question, please try to check the following blog:
    #How to call a WCF service from JQuery:
    http://blog.thomaslebrun.net/2011/11/jquery-calling-a-wcf-service-from-jquery/#.UoXBhiSwqM8 .

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, November 15, 2013 6:41 AM
    Moderator
  • Hi Amy,

    Thanks for your reply.

    I have already tried the same given service configurations for IIS hosting (Instead of selfhosting) and I am not able to call mex endpoint or other endpoint.

    I have another question (it might be basic question) based on your config, how would I create WCF service without .svc extension (Like http://localhost:8733/Service1/mex or http://localhost:8733/Service1). I have seen the same wcf service url pattern at many places but could not understand it. Is it something related URL Redirection or related to configuration. can you please explain.

    Thanks


    Rakesh Kumar

    Friday, November 15, 2013 11:28 AM
  • Hi,

    If you want to create the wcf service without .svc extension, please try to check the following:
    #WCF Service on IIS. How to get rid of the “Service.svc” component in the URL path:
    http://stackoverflow.com/questions/11440562/wcf-service-on-iis-how-to-get-rid-of-the-service-svc-component-in-the-url-pat .

    #WCF removing .svc extention:
    http://stackoverflow.com/questions/7354616/wcf-removing-svc-extention .

    Or you can just use the httpGetUrl:

      <serviceMetadata httpGetEnabled="true" httpGetUrl=http://localhost:80/services/>

    Then you can use the httpGetUri address to get the wsdl, also the client can use this uri to call the wcf services.

    #ServiceMetadataBehavior.HttpGetUrl Property:
    http://msdn.microsoft.com/en-us/library/system.servicemodel.description.servicemetadatabehavior.httpgeturl(v=vs.110).aspx .

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, November 28, 2013 10:24 AM
    Moderator