Reputation: 49
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"/>
</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 :)
Upvotes: 0
Views: 1290
Reputation: 755471
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
Upvotes: 1
Reputation: 2683
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>
Upvotes: 1
Reputation: 118935
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.
Upvotes: 0