tags:

views:

281

answers:

3

I am a beginner of WCF,I write a simple example of it,and the app.config files of my application as follows:

Host:

<services>

  <service name="WCFService.Service.CalculatorService" behaviorConfiguration="calculatorBehavior">

    <host>
      <baseAddresses>
        <add baseAddress="http://10.1.9.210:8080/GeneralCalculator"/&gt;
      </baseAddresses>
    </host>

    <endpoint address="" binding ="basicHttpBinding" contract="WCFService.Contract.ICalculator"></endpoint>

  </service>

</services>

<behaviors>

  <serviceBehaviors>
    <behavior name="calculatorBehavior">
      <serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
    </behavior>
  </serviceBehaviors>      
</behaviors>


Client:

<client>

  <endpoint address="http://10.1.9.210:8080/GeneralCalculator/CalculatorService" binding ="basicHttpBinding" contract="WCFService.Contract.ICalculator" />

</client>

When I run my application,there is an exception: "The message with To 'http://10.1.9.210:8080/GeneralCalculator/CalculatorService' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree."

I guess there are some wrong with my configuration file and please give me some hint,

thanks :)

A: 

Looks like the client is trying to hit a Uri that ends in "CalculatorService", whereas the service does not have this suffix on the Uri? Change the address on the client to match that of the service.

Brian
thank you very much
Leo Zhang
+1  A: 

Try this instead:

<services>

  <service name="WCFService.Service.CalculatorService" behaviorConfiguration="calculatorBehavior">

    <host>
      <baseAddresses>
        <add baseAddress="http://10.1.9.210:8080/GeneralCalculator"/&gt;
      </baseAddresses>
    </host>

    <endpoint address="CalculatorService" binding ="basicHttpBinding" contract="WCFService.Contract.ICalculator"></endpoint>

  </service>

</services>

<behaviors>

  <serviceBehaviors>
    <behavior name="calculatorBehavior">
      <serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
    </behavior>
  </serviceBehaviors>

</behaviors>
Rodrigo Guerreiro
the problem is solved thank you very much :)
Leo Zhang
Please mark as answered and choose the right answer from all the answers. Thanks.
Rodrigo Guerreiro
A: 

Your client tries to connect to:

http://10.1.9.210:8080/GeneralCalculator/CalculatorService

while your server exposes the service at:

http://10.1.9.210:8080/GeneralCalculator

These two need to match! :-)

So you can either use Rodrigo's answer and add an relative address="CalculatorService" to your server's endpoint, or you could change the client's endpoint to point to the same URL as the server exposes right now.

Marc

marc_s
thank you very much
Leo Zhang