I have searched on here for the exact solution to my problem to no avail.
I have added a Web Service to my project but am unable to reference it. Clicking Discover works fine - the service is available but when it comes to retrieving a list of services at its location the following text appears:
The HTML document does not contain Web service discovery information.
Metadata contains a reference that cannot be resolved:
Metadata contains a reference that cannot be resolved:
'http://localhost:57657/Services/AFDiscovery.svc'.
If the service is defined in the current solution, try building the solution and
adding the service reference again.
How do I fix this? I am attempting to run the service locally so I do not need to add it within IIS.
Web.config information:
<services>
<service name="WebServiceInterface.AFDiscovery">
<endpoint address="" binding="wsHttpBinding" contract="WebServiceInterface.AFDiscovery" />
</service>
</services>
You can add the project containing the WebServiceInterface.AFDiscovery in your solution. Then in the project using the web service, when you add your reference, instead of clicking "Discover", use the load from project option.
If you want to load the reference via a URL (Discover button), try browsing to "http://localhost:57657/Services/AFDiscovery.svc?WSDL" in your browser. If you get a message saying the metadata isn't accessible, you must modify your web service web.config.
Check this link for configuring the web.config: http://msdn.microsoft.com/en-us/library/aa751951.aspx
It should look similar to:
<configuration>
<system.serviceModel>
<services>
<service
name="WebServiceInterface.AFDiscovery"
behaviorConfiguration="SimpleServiceBehavior">
<endpoint address=""
binding="wsHttpBinding"
contract="WebServiceInterface.IAFDiscovery" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="SimpleServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
One of the possibility is the service name in your Web.config does not
match the namespace in your class file.Make sure the names are the
same then try again.
Refer
And double Check your Service MarkUp code by reghclick and Choose MarkUp
Related
I have a very weird problem with a 3 tiers client/server application with WCF.
First, I have a service windows which host WCF services in basicHttpBinding. This is the server app.config :
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service name="Business.BSServiceManagement" behaviorConfiguration="myServiceBehave">
<host>
<baseAddresses>
<add baseAddress="http://localhost:35001"/>
</baseAddresses>
</host>
<endpoint address="/Clients" binding="basicHttpBinding" name="Clients" contract="Contracts.BusinessFacade.IBFClientManagement"/>
<endpoint address="/Users" binding="basicHttpBinding" name="Users" contract="Contracts.BusinessFacade.IBFUserManagement"/>
<endpoint address="/Licences" binding="basicHttpBinding" name="Licences" contract="Contracts.BusinessFacade.IBFLicenceManagement"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="myServiceBehave">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
This service is deployed on a server in DMZ and I have access from my computer (in firefox, if I put service address with port number)
Secondly, I have a client application made with winforms which consume the service with ChannelFactory.
This is the client app.config :
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<client>
<endpoint address="http://192.168.128.1:35001/Clients" binding="basicHttpBinding" name="Clients" contract="Contracts.BusinessFacade.IBFClientManagement"/>
<endpoint address="http://192.168.128.1:35001/Users" binding="basicHttpBinding" name="Users" contract="Contracts.BusinessFacade.IBFUserManagement"/>
<endpoint address="http://192.168.128.1:35001/Licences" binding="basicHttpBinding" name="Licences" contract="Contracts.BusinessFacade.IBFLicenceManagement"/>
</client>
</system.serviceModel>
</configuration>
When I debug client application, all works perfectly. So I've made a installer project to deploy application on several computers but when I execute exe of application (installed or directly in bin/release), I have an error message like this :
There was no endpoint listening at http://192.168.128.1:35001/Users...
The inner exception says:
Unable to connect to the remote server
I tried adding mex endpoint, change port number, check server and client computer firewall, I don't understand where is the problem.
Thanks for your help.
EDIT 1 :
After several tests I have the same problem in release exe but not in debug exe.
If I execute the debug exe all works fine but the release exe return the error message.
The problem is with your Service.
Make sure that the Service is Started and running.
Once you start the Service, browse URL(eg: localhost:8080/example), just to make sure Service is running fine.
When you add Service Reference to your client Application, it automatically generates endpoints in app.config file.
When you added Installer to client project, make sure that it is builds Successfully.
When you install it, it should work for you.
I have two project in my machine. In first application i have created WCF service it works correct only i have tested, hosting in console application after hosting press Ctlr+F5 displaying message Host started # 13-Jan-16 12:28:01 PM...
Where as in second application i am trying to add Add Service reference showing an error....
There was an error downloading 'http://localhost:8035/_vti_bin/ListData.svc/$metadata'.
Unable to connect to the remote server
No connection could be made because the target machine actively refused it 127.0.0.1:8035
Metadata contains a reference that cannot be resolved: 'http://localhost:8035/'.
There was no endpoint listening at http://localhost:8035/ that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
Unable to connect to the remote server
No connection could be made because the target machine actively refused it 127.0.0.1:8035
If the service is defined in the current solution, try building the solution and adding the service reference again.
App.config: host application...
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehaviour">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="HelloService.HelloService" behaviorConfiguration="mexBehaviour">
<endpoint address="HelloService" binding="basicHttpBinding" contract="HelloService.IHelloService">
</endpoint>
<endpoint address="HelloService" binding="netTcpBinding" contract="HelloService.IHelloService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8035/" />
<add baseAddress="net.tcp://localhost:8032"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
</configuration>
I have a WCF project (:53763/WCFTestService.svc) and a web application(:50238/CSharp/test.aspx) in C#. I am trying to call the WCF project method in my web application. I have added the WCF project as a service reference in web application.
in test.aspx.cs file I have a method as follows
[WebMethod()]
public static string GetWCF()
{
WCFTestServiceClient client = new WCFTestServiceClient();
string result = client.XMLData("1122");
return result;
}
When I run this getting error :
Could not find default endpoint element that references contract
'TestWCFServiceReference.IWCFTestService' in the ServiceModel client
configuration section. This might be because no configuration file was
found for your application, or because no endpoint element matching
this contract could be found in the client element
.
When I add the WCF project as a service reference in my web application, the web.config file in the web application is not updated automatically. (No code is added by default at the time of adding reference).
Do I need to add anything in the web.config file for making it working?
web.config of WCF project is:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="WCFTestService.RestService" behaviorConfiguration="ServiceBehaviour">
<endpoint address="" binding="webHttpBinding" contract="WCFTestService.IRestService" behaviorConfiguration="web">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
<!--<behavior>
--><!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --><!--
<serviceMetadata httpGetEnabled="true"/>
--><!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --><!--
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>-->
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
It sounds like there's an error you're going to need to resolve when you reference your WCF project. Look on your information tab (not warning/errors) on Visual Studio when you add the reference and you'll see the errors. I'm guessing it'll have something to do with Newtonsoft.Json - which there are many posts about, such as Error adding service reference: Type is a recursive collection data contract which is not supported
In your configuration file you have only one endpoint with webHttpBinding that is used for restful address. So you can refer here to configure and test restful service. or add another endpoint to provide service metadata for SOAP client e.g.
<endpoint address="" binding="basicHttpBinding" contract="WCFTestService.IRestService" bindingNamespace="">
</endpoint>
I am getting a Bad Request (Invalid host) when trying to run my C# WCF service under mono. This service is part of an application, not being hosted using a web server.
I have configured my services with the following:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="DefaultServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="DefaultServiceBehavior" name="MyServices.TaskService">
<endpoint address="V1" binding="basicHttpBinding" contract="MyServices.ITaskServiceV1" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8731/MyServices/Tasks" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
When I try to visit http://localhost:8731/MyServices/Tasks or any of its endpoints (including ?wsdl), I get the 400 error.
I have deployed this successfully using the .net runtime, just can't figure out what's wrong for deploying with mono. Any help would be greatly appreciated.
EDIT Mono version: 2.10.1
I had the same issue today.
Hosting a wcf service inside a .net 3.5 application worked but same code using mono 3.2.2 gives invalid host error response.
So I checked mono source and found out that mono searches for a valid endpoint from request url using case sensitive compare. Changed my url to fit case like in my service config resolved the issue.
I am using IIS 7.0 to host a simple WCF service. I write it by using VSTS 2008 + .Net 3.5 + C#. The issue is when I access http://localhost:9999/service.svc (I suppose in web browser we can browse the content of WSDL, and I create a new web site which uses port 9999 and run application pool under administrator account), I am met with the following error, any ideas what is wrong?
http://i27.tinypic.com/a9r8cz.jpg
Here is my service.svc:
<%# ServiceHost Language="C#" Service="Gu.WCF.StudentManagement" %>
Here is my web.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="Gu.WCF.ServiceBehavior"
name="Gu.WCF.StudentManagement">
<endpoint address="" binding="basicHttpBinding" contract="Gu.WCF.IStudentManagement">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Gu.WCF.ServiceBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Sounds like the .NET 3.0 ISAPI mappings have vanished. In the .NET 3.0 WCF directory (C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation) run ServiceModelReg -r
Please make sure that you have the .svc extension mapped to the ISAPI handler.