I'm setting up bare bones hello world WCF service, using the Visual Studio WCF Service Application template. I removed the "value" parameter from the out-of-the-box GetData function, so that it can take a "bare" GET request.
[OperationContract]
[WebGet]
string GetData();
But I keep getting this error:
"The message with To 'http://<my hostname>/service1.svc/getdata' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.
To get rid of this error, I have to add a behaviorConfiguration property to the service element in web.config. Why doesnt the webHttpBinding have this behavior inbuilt? Moreover, if I try to use wsHttpBinding, I get 400, bad request. Please note I'm making all requests through IE address field, not a WCF client:
Thanks mm10. Good point. Could you please tell me why I need to add a behaviorConfiguration to get rid of the error:
The message with To '<myhostname>/Service1.svc/getdata' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.
The WebHttpBehavior behavior is used in conjunction with the WebHttpBinding to expose and access services accessed from the web.
If you use a WebHttpBinding without the WebHttpBehaviour, you will get a HTTP 500 Internal Server Error. The error message you are mentioning will probably become a 500 Internal Server error if you remove the address from endpoint configuration.
As mm10 has explained, the <webHttp> behavior element helps inject some webHttpBinding(restful binding for WCF) specific extensions so that the underlying service/endpoint processing stack get changed to fit the RESTful programming model.
By default, SOAP/XML based message processing mechansim is used and as the error you have encounterred. SOAP/XML based messaging will rely on some SOAP specific feature(like the soapAction header in message) to determine which operation an incoming request
is targeting. While for REST/web style service, the request URL itself has indicated the target operation it want to invoke.
Here are some further reference about WCF REST programming model:
greatbear
Member
160 Points
189 Posts
webHttpBinding not enough for browser based GET??
Mar 29, 2012 05:27 PM|LINK
I'm setting up bare bones hello world WCF service, using the Visual Studio WCF Service Application template. I removed the "value" parameter from the out-of-the-box GetData function, so that it can take a "bare" GET request.
But I keep getting this error:
"The message with To 'http://<my hostname>/service1.svc/getdata' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.
To get rid of this error, I have to add a behaviorConfiguration property to the service element in web.config. Why doesnt the webHttpBinding have this behavior inbuilt? Moreover, if I try to use wsHttpBinding, I get 400, bad request. Please note I'm making all requests through IE address field, not a WCF client:
<service name="TestWCF.Service1"> <endpoint address="http://127.0.0.1/Service1.svc/" binding="webHttpBinding" behaviorConfiguration="my" contract="TestWCF.IService1"> </endpoint> </service> <behaviors> <endpointBehaviors> <behavior name="my"> <webHttp defaultBodyStyle="Bare"/> </behavior> </endpointBehaviors> ... </behaviors>mm10
Contributor
6455 Points
1187 Posts
Re: webHttpBinding not enough for browser based GET??
Mar 30, 2012 08:25 AM|LINK
Remove the address in your endpoint. When you host a WCF service in IIS, it is reachable at the URL of the .svc-file.
<endpoint address=""
binding="webHttpBinding"
behaviorConfiguration="my"
contract="TestWCF.IService1">
</endpoint>
greatbear
Member
160 Points
189 Posts
Re: webHttpBinding not enough for browser based GET??
Mar 30, 2012 09:01 PM|LINK
Thanks mm10. Good point. Could you please tell me why I need to add a behaviorConfiguration to get rid of the error:
The message with To '<myhostname>/Service1.svc/getdata' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.
mm10
Contributor
6455 Points
1187 Posts
Re: webHttpBinding not enough for browser based GET??
Mar 30, 2012 09:11 PM|LINK
The WebHttpBehavior provide the correct networking stack for using REST. You can read more in this article: http://msdn.microsoft.com/en-us/magazine/dd315413.aspx.
Does your service work now or do you still get the same error message?
greatbear
Member
160 Points
189 Posts
Re: webHttpBinding not enough for browser based GET??
Mar 30, 2012 09:21 PM|LINK
The service works, it has been working, My original question is that it does not work if I remove the following custom behaviorConfiguration:
<endpointBehaviors>
<behavior name="my">
<webHttp defaultBodyStyle="Bare" />
</behavior>
</endpointBehaviors>
mm10
Contributor
6455 Points
1187 Posts
Re: webHttpBinding not enough for browser based GET??
Mar 31, 2012 08:58 AM|LINK
The WebHttpBehavior behavior is used in conjunction with the WebHttpBinding to expose and access services accessed from the web.
If you use a WebHttpBinding without the WebHttpBehaviour, you will get a HTTP 500 Internal Server Error. The error message you are mentioning will probably become a 500 Internal Server error if you remove the address from endpoint configuration.
Steven Cheng...
Contributor
4219 Points
548 Posts
Microsoft
Moderator
Re: webHttpBinding not enough for browser based GET??
Apr 02, 2012 03:00 AM|LINK
Hi greatbear,
As mm10 has explained, the <webHttp> behavior element helps inject some webHttpBinding(restful binding for WCF) specific extensions so that the underlying service/endpoint processing stack get changed to fit the RESTful programming model.
By default, SOAP/XML based message processing mechansim is used and as the error you have encounterred. SOAP/XML based messaging will rely on some SOAP specific feature(like the soapAction header in message) to determine which operation an incoming request is targeting. While for REST/web style service, the request URL itself has indicated the target operation it want to invoke.
Here are some further reference about WCF REST programming model:
#WCF RESTful Programming Model
http://msdn.microsoft.com/en-us/library/orm-9780596519209-01-02.aspx
#WCF Web HTTP Programming Model Overview
http://msdn.microsoft.com/en-us/library/bb412172.aspx
BTW, for creating WCF REST style service, you can also use the predefined Visual Studio template below:
#WCF REST Service Template 40(CS)
http://visualstudiogallery.msdn.microsoft.com/fbc7e5c1-a0d2-41bd-9d7b-e54c845394cd
Feedback to us
Microsoft One Code Framework