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:)
a source to share
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>
a source to share
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
a source to share