WCF Error : Relative end point addresses

前端 未结 3 2066
死守一世寂寞
死守一世寂寞 2021-02-19 15:40

Um quite new to WCF . I think I have messed up a bit. So this is what I did so far and I ve hosted my WCF service in IIS

First the Contracts

using System         


        
相关标签:
3条回答
  • 2021-02-19 16:16

    This works for me:

    1. Insert this lines inside service:

     <host>
          <baseAddresses>
            <add baseAddress="http://localhost:7000/Service1.svc" />
          </baseAddresses>
        </host>
    

    2. Set the value of address as bellow:

    address=""

    The full code:

    <service name="YangkeeServer.Service1">
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:7000/Service1.svc" />
              </baseAddresses>
            </host>
            <endpoint
               contract="YangkeeServer.IService1"
              binding="webHttpBinding"
              behaviorConfiguration="WebHttp"
              address="">
            </endpoint>
          </service>
    
    0 讨论(0)
  • 2021-02-19 16:26

    Set the service endpoint address to just the service filename (this is the relative part):

    address="Service1.svc"
    

    or set the address to blank for each endpoint (I don't think its needed when hosting in the development environment or in IIS)

    address=""
    

    See this answer to another question

    The relevant part is:

    the virtual directory (in IIS) where your *.svc file exists defines your service endpoint's address.

    0 讨论(0)
  • 2021-02-19 16:27

    To fix this error, I added... listenUri="/" ... to the service endpoint.

    Example:

    <service name="_name_">
      <endpoint address="http://localhost:_port_/.../_servicename_.svc"
        name="_servicename_Endpoint" 
        binding="basicHttpBinding"
        bindingConfiguration="GenericServiceBinding"
        contract="_contractpath_._contractname_"
        listenUri="/" />
    </service>
    

    MSDN: Multiple Endpoints at a Single ListenUri

    0 讨论(0)
提交回复
热议问题