Self-hosted Wcf serves as wsdl, but 404 when called

I'm trying to host one instance of the service myself, and I'm obviously lost on the level of indirection ...

I have a base address http://localhost:8050/ . I'm not too worried about where the endpoint of the service is as long as it is predictable. I'm currently trying to use /Manage/ .

I can go to the base address and see wsdl. If I look through wsdl, it points to /Manage/ ..

 <wsdl:service name="EngineService"> <wsdl:port name="BasicHttpBinding_IEngineService" binding="tns:BasicHttpBinding_IEngineService"> <soap:address location="http://localhost:8050/Manage/"/> </wsdl:port> </wsdl:service> 

When I use wsdl using WcfTestClient , it lists all the correct methods, but calling any of them throws the following exception

System.ServiceModel.EndpointNotFoundException: there was no listening to endpoints at http: // localhost: 8050 / Manage that could receive this message. This is often caused by the wrong address or SOAP action. See InnerException, if present, for more details.

 Server stack trace: at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason) at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at IEngineService.SupportedAgents() at EngineServiceClient.SupportedAgents() Inner Exception: The remote server returned an error: (404) Not Found. at System.Net.HttpWebRequest.GetResponse() at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) 

Log messages show that my instance methods are never called. The service does not enter an error state; it just looks as if it is missing.

I am listening to the following:

  public static ServiceHost Listen<TServiceContract>( TServiceContract instance, int port, string name ) { //Added this for debugging, was previously just "name" string endpoint = String.Format("http://localhost:{0}/{1}/", port, name); var svcHost = new ServiceHost( instance, new Uri[] { new Uri(String.Format("http://localhost:{0}/", port)) }); /* Snip: Add a Faulted handler but it never called */ ServiceEndpoint serviceHttpEndpoint = svcHost.AddServiceEndpoint( typeof(TServiceContract), new BasicHttpBinding { HostNameComparisonMode = HostNameComparisonMode.WeakWildcard }, endpoint); /*Using name instead of endpoint makes no difference beyond removing the trailing slash */ /* Snip: Add a ServiceDebugBehavior with IncludeExceptionDetailInFaults = true */ /* Snip: Add a ServiceMetadataBehavior with HttpGetEnabled = true */ try { log.Trace("Opening endpoint"); svcHost.Open(); } catch () { /* Lots of catches for different problems including Exception * None of them get hit */ } log.Info("Service contract {0} ready at {1}", typeof(TServiceContract).Name, svcHost.BaseAddresses.First()); return svcHost; 

And calling the Listen() method as follows:

  IEngineService wcfInstance = Resolver.Resolve<IEngineService>(); service = WcfHoster.Listen(wcfInstance, 8050, "Manage"); 

How can I track that the / debug problem is next?

Additional information: service contract and minimum implementation:

 [ServiceContract] interface IEngineService { [OperationContract] List<string> Agents(); [OperationContract] string Test(); [OperationContract] List<string> SupportedAgents(); [OperationContract] string Connect(string AgentStrongName, string Hostname); } 

And implementation:

 [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)] class EngineService : IEngineService { IAgentManager agentManager; public EngineService(IAgentManager AgentManager) { log.Debug("Engine webservice instantiating"); this.agentManager = AgentManager; } public string Connect(string AgentStrongName, string Hostname) { log.Debug("Endpoint requested for [{0}], [{1}]", Hostname, AgentStrongName); return agentManager.GetSession(AgentStrongName, Hostname); } public List<string> Agents() { log.Debug("Current agents queried"); throw new NotImplementedException(); } public List<string> SupportedAgents() { log.Debug("Supported agents queried"); return agentManager.SupportedAgents().ToList(); } public string Test() { log.Warn("Test query"); return "Success!"; } } 

The test client can see the service and methods, but it throws an exception above when I click Invoke ...

enter image description here

Edit: localhost allows IPv6 by default, so I tried to use 127.0.0.1 explicitly at both ends. No difference.

I tried using this code in a new project and getting the same problem. Doing all this on someone else's machine didn’t help either.

Trace Viewer

Running a server-side service trace and then viewing the results in the viewer gives:

Could not find the channel to receive the incoming message. Either the endpoint or the SOAP action was not found.

enter image description here

Configuration file. Since I need an executable to be able to decide which Wcf service will be displayed at runtime, I do not have any Wcf-related code in the configuration file.

+8
c # soap wsdl web-services wcf
source share
1 answer

This is probably a client / service binding mismatch. Check the binding of the test client. You must also create a unit test by creating a proxy server from wsdl.

Ok I tried to reproduce your problem and I managed to call the host by deleting "HostNameComparisonMode = HostNameComparisonMode.WeakWildcard" to get the default basichttp endpoint. Why do you need this?

+3
source share

All Articles