WCF question when using app.config

I am starting WCF, I am writing a simple example and my application's app.config files like this:

Host:

<services>

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

    <host>
      <baseAddresses>
        <add baseAddress="http://10.1.9.210:8080/GeneralCalculator"/>
      </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, an exception is thrown: "Message from" http://10.1.9.210:8080/GeneralCalculator/CalculatorService 'could not be processed in the receiver due to an AddressFilter mismatch in the EndpointDispatcher. Make sure the sender and receiver EndpointAddresses agree. "

I think there are some errors in my config file and please give me a little hint,

thanks:)

0


a source to share


3 answers


Try this instead:



<services>

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

    <host>
      <baseAddresses>
        <add baseAddress="http://10.1.9.210:8080/GeneralCalculator"/>
      </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>

      

+1


a source


Your client is trying to connect to:

http://10.1.9.210:8080/GeneralCalculator/CalculatorService

      

while your server provides the service at:

http://10.1.9.210:8080/GeneralCalculator

      



These two need to match! :-)

So you can use Rodrigo's answer and add a relative address="CalculatorService"

to the server endpoint, or you can change the client endpoint to point to the same url as the server provided right now.

Mark

+1


a source


It looks like the client is trying to hit a Uri that ends in "CalculatorService" whereas the service doesn't have that suffix on the Uri? Change the address on the client to match the service address.

0


a source







All Articles