Search code examples
wcfc#-4.0wcf-binding

Support multiple urls for same WCF service (as web url rewrite)


I have a WCF service hosted by IIS. It is documented to programmers as service end point; https://api.company.com/services/soap1

but client must define endpoint https://api.company.com/services/soap1/

Question; How can I support them also without pain? Is there any way like url re-write for wcf services requests add last trail automaticaly?

note: service work with mtom encoding SOAP messages.


Solution

  • WCF allows you to configure multiple endpoints for the same service.

    <services>
     <servicename ="MultipleEndpoints.Service1" behaviorConfiguration ="Mg">
        <endpointname="firstBinding"
          address ="https://api.company.com/services/soap1"
          binding ="basicHttpBinding"
          contract ="MultipleEndpoints.IService1" />
         <endpointname="secondBinding"
           address ="https://api.company.com/services/soap1/"
           binding ="basicHttpBinding"
          contract ="MultipleEndpoints.IService1"/>
        <endpointcontract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
     </service>
     </services>
    

    For an example see: http://www.c-sharpcorner.com/uploadfile/dhananjaycoder/configuring-multiple-end-points-for-wcf-service/