0
Answer

WCF within MVC issue

Ali Mahmoud

Ali Mahmoud

10y
1.2k
1
I hosted the WCF successfully and I can call it using url like within MVC web application http://localhost:49829/SchollWebService.svc

but from browser I cannot use simple method which return string if I tried this URL

http://localhost:49829/SchollWebService.svc/TestWCF

gives error

<?xml version="1.0"?>  <Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none"> <Code> <Value>Sender</Value> <Subcode> <Value xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">a:DestinationUnreachable</Value> </Subcode> </Code> <Reason> <Text xml:lang="en-US">The message with To 'http://localhost:49829/SchollWebService.svc/TestWCF' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. Check that the sender and receiver's EndpointAddresses agree.</Text> </Reason> </Fault>

or

http://localhost:49829/SchollWebService/TestWCF

gives error

Value cannot be null. Parameter name: contract

my route config looks like

routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); // For Admin Screens routes.MapRoute("Admin", "Admin/{name}", new { controller = "Admin", action = "Redirect", name = "" }); // For general and WCF Configuration routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional }, new { controller = "^(?!SchollWebService).*" }); routes.Add(new ServiceRoute("SchollWebService", new WebServiceHostFactory(), typeof(SchollWebServiceClient.SchollWebServiceClient)));

", new WebServiceHostFactory(), typeof(ArabicEWorldWebServiceClient.ArabicEWorldWebServiceClient)));

where ArabicEWorldWebServiceClient is service reference I need when host to use both the MVC and the WCF (which will be used to communicate with other apps )

my web,config looks like the answer at wcf web.config file

How to solve that please, am I missing something