WCF Error : Relative end point addresses

雨燕双飞 提交于 2019-12-04 02:01:23
Paul Anderson

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.

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

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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!