WCF Error on execute: Manual addressing is enabled on this factory, so all messages sent must be pre-addressed
I realize that only WebHttpBinding has this problem. To solve this problem, just add a behavior configuration in the client side configuration file like this:
<behaviors>
<endpointBehaviors>
<behavior name="webEndpoint">
<webHttp defaultBodyStyle="Wrapped"
defaultOutgoingResponseFormat="Xml"
helpEnabled="true"/>
</behavior>
</endpointBehaviors>
</behaviors>
Then, update the client endpoint to use the above endpoint behavior.
<client>
<endpoint binding="webHttpBinding"
bindingConfiguration="webHttp"
behaviorConfiguration="webEndpoint"
contract="ExpenseService.IExpenseService"
address="http://myservices/ExpenseService.svc">
</endpoint>
</client>
The problem should be solved.
Amintabar
Experienced Software Developer with a demonstrated history of working in software production and development confident, ambitious and passionate individual with an extreme desire for learning, progress, and success, who wants to join an intelligent and new technology, creative and flexible team to improve knowledge and programming expertise and willingness to work in a dynamic environment for creative ideas. And finally, Just a tech lover person.
Updated on June 13, 2022Comments
-
Amintabar almost 2 years
I have a WCF service hosted with WebHttpBinding. The service is very simple, an operation contract which accept multiple parameters. My WCF client, auto generated after using the "Add Service Reference", is not able to directly consume the WCF service. The error only occur for WebHttpBinding but not the others.
Server Side
[OperationContract] [WebInvoke(Method = "POST", UriTemplate = "Submit2String", RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Wrapped)] string Submit2String(string input1, string input2);
Client Side
ExpenseServiceClient proxy = new ExpenseServiceClient(); proxy.Submit2String("test1", "test2");
When I test run my above code, I get the following error:
Error: InvalidOperationException was unhandled by user code Manual addressing is enabled on this factory, so all messages sent must be pre-addressed.
Here is how my auto generated configuration file look like after using the "Add Service Reference":
<system.serviceModel> <bindings> <webHttpBinding> <binding name="webHttp"> <security mode="None"> <transport clientCredentialType="None" /> </security> </binding> </webHttpBinding> </bindings> <client> <endpoint binding="webHttpBinding" bindingConfiguration="webHttp" contract="ExpenseService.IExpenseService" address="http://localhost/myservices/ExpenseService.svc"> </endpoint> </client> </system.serviceModel>
-
ryanwebjackson over 6 yearsWhat should the <webHttpBinding> configuration look like?