WCF Error : Manual addressing is enabled on this factory, so all messages sent must be pre-addressed

WCF Error : Manual addressing is enabled on this factory, so all messages sent must be pre-addressed

 

回答2

I added a service reference as usual and got this error. Turns out all I had to do was to amend the client config to use an endpoint config with a behaviour specifing webhttp

<client>
  <endpoint address="http://localhost:9000/GeoConverterService/GeoConverterService.svc"
            binding="webHttpBinding" 
            contract="GeoConverter.IGeoConverterService" 
            behaviorConfiguration="webhttp"/>
</client>

<behaviors>
  <endpointBehaviors>
    <behavior name="webhttp">
      <webHttp/>
    </behavior>
  </endpointBehaviors>
</behaviors>

 

可能会遇到http 405错误,给contract的method加上WebGet这个attribute可以解决

 

posted @ 2023-05-05 15:22  ChuckLu  阅读(51)  评论(0编辑  收藏  举报