I am having an issue where I can't add a service reference in Visual Studio 2010 via a URL.
I have my HOST file setup to resolve http://mydomain.com locally, and setup my web.config file to reference this url. However when I go to add a service reference by URL I get the following error:
Metadata contains a reference that cannot be resolved: 'http://mydomain.com/myservice.svc?wsdl'.
The WSDL document contains links that could not be resolved.
There was an error downloading 'http://mydomain.com/myservice.svc?xsd=xsd0'.
The underlying connection was closed: An unexpected error occurred on a receive.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
An existing connection was forcibly closed by the remote host
Metadata contains a reference that cannot be resolved: 'http://mydomain.com/myservice.svc'.
There was no endpoint listening at http://mydomain.com/myservice.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
The remote server returned an error: (404) Not Found.
The other URLS work fine:
http://mydomain.com/myservice.svc?wsdl and http://mydomain.com/myservice.svc
Here is my web.config file:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<!-- Note: the service name must match the configuration name for the service implementation. -->
<service name="FuncWS.Email" behaviorConfiguration="ServiceType" >
<!-- Add the following endpoint. -->
<endpoint address="myservice.svc" binding="webHttpBinding" contract="FuncWS.IEmail"></endpoint>
<!-- Note: your service must have an http base address to add this endpoint. -->
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
<host>
<baseAddresses>
<add baseAddress="http://mydomain.com"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceType">
<!-- 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>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
The solution to this problem is that IIS needs to have rights to the C:\Windows\Temp folder. Without this it can't generate the meta data needed.
Related
I am hosting Wcf application on my local machine(32 bit machine).I am getting below error.
Config Error This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
Attaching the Config file details for the same.
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="WcfServiceDemo.ServiceCalculateCost" >
<endpoint address="" binding="wsHttpBinding" contract="WcfServiceDemo.IServiceCalculateCost"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<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>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
IIS 7 implements "Configuration Locking". This is to help with IIS administration.
Here, look at the error details and how to resolve the same: IIS 7 – This configuration section cannot be used at this path.
As per it, one of the resolution:
Open the applicationHost.config file, located here: %windir%\system32\inetsrv\config\applicationHost.config
Edit the "handlers" section.
Change this line:
<section name=”handlers” overrideModeDefault=”Deny” />
To:
<section name=”handlers” overrideModeDefault=”Allow” />
Using .Net 3.5. Trying to provide a WCF - Json service.
Looked for implementation examples and after failing with a few went with Code Project "How to create a JSON WCF RESTful Service in 60 seconds"
This is my App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="WcfJsonRestService.Service1" behaviorConfiguration="WcfJsonRestService.Service1Behavior">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8732/Design_Time_Addresses/WcfJsonRestService/Service1/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address ="http://localhost:8732/service1" binding="webHttpBinding" contract="WcfJsonRestService.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="WcfJsonRestService.Service1Behavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="WcfJsonRestService.Service1Behavior">
<!-- 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>
In my browser I run:
`http://localhost:8732/Service1/data/10`
And I get
<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-GB">
The message with To 'http://localhost:8732/Service1/data/10' 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>
Help would be appreciated
try to add this
[ServiceBehavior(AddressFilterMode=AddressFilterMode.Any)]
I'm developing a REST service using WebHttpBinding.
Everything is perfect in my service, but while running it gives Error Endpoint not Found.
The web.config File is like this:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<services>
<service name="Service">
<endpoint address="http://localhost:10492/Service.svc" binding="webHttpBinding" contract="IService" behaviorConfiguration="webby"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webby">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false 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>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
In address I tried like this also:
<endpoint address="" binding="webHttpBinding" contract="IService" behaviorConfiguration="webby"/>
But it's still not working.
Here is a good link to get you started: http://weblogs.asp.net/kiyoshi/archive/2008/10/08/wcf-using-webhttpbinding-for-rest-services.aspx
On what address are you attempting to connect to your web service? (Have you tried navigating to the address in your web browser, and what URL did you type in?)
[EDIT]
Being that you are hosting in a web application, IIS (or whatever web server you are using) will expect that a service descriptor file exists for your service. You cannot just create a URI in the web.config, and host it in IIS without an associated 'service' file on the file-system (this is your Service1.svc file).
This is a nuance specific to hosting WCF services within Internet Information Services - it is easy to forget about this step, if you are reading tutorials designed for self-hosted scenarios.
Make sure that you have a file in your website called "Service1.svc" and it should contain something like this:
<%#ServiceHost Language="C#" Service="MyNamespace.Service1" Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>
Here is a tutorial on hosting REST services within IIS: http://saravananarumugam.wordpress.com/2011/03/04/simple-rest-implementation-with-webhttpbinding/
Another concern that jumps out at me, is that your endpoint address you have defined ("http://localhost:10492/Service.svc") does not conform to REST conventions. I wouldnt expect this would be your problem, but it is A problem.
Hi I have deployed the WCF web service on the server machine. I am able to browse it in browser. but when i am going to add its service reference to my web application on development machine I am getting following detail error:
Metadata contains a reference that cannot be resolved:
'http://ServerMachineName:500/ITCAMSWebService_deploy/Services/Authentication.svc?wsdl'.
The WSDL document contains links that could not be resolved.
There was an error downloading 'http://ServerMachineName:500/ITCAMSWebService_deploy/Services/Authentication.svc?xsd=xsd0'.
The underlying connection was closed: An unexpected error occurred on a receive.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
An existing connection was forcibly closed by the remote host
Metadata contains a reference that cannot be resolved: 'http://ServerMachineName:500/ITCAMSWebService_deploy/Services/Authentication.svc'.
Content Type application/soap+xml; charset=utf-8 was not supported by service
http://ServerMachineName:500/ITCAMSWebService_deploy/Services/Authentication.svc.
The client and service bindings may be mismatched.
The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8'
was not the expected type 'text/xml; charset=utf-8'..
If the service is defined in the current solution, try building the solution and adding the service reference again.
Generated Service Model section in Web.config at server is as follows:
<system.serviceModel>
<services>
<service name="Authentication" behaviorConfiguration="Behavior_Authentication">
<host>
<baseAddresses>
<add baseAddress="http://ServerMachineName:500/ITCAMSWebService_deploy/Services/Authentication.svc"></add>
</baseAddresses>
</host>
<endpoint address="" contract="IAuthentication" binding="basicHttpBinding" bindingConfiguration="ITCAMSWebService.IAuthentication" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<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="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483646" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
</system.serviceModel>
Resolved !!! By adding Everyone user with full rights to C:\Windows\Temp on the server. IIS needs the rights to generate Metadata file in Temp folder on the server.
Please give ip address of your server in the address instead of ServerMachineName and also check the bindings of both client n server
I currently have a wcf service library project that includes my service contract & implementation. If I were to go to a web project within the same solution and add a service reference and click on the discover button, I can see my service listed as http://..design_time_address/myservice listed.
Now if i were to go ahead and move my service contract & implementation classes to another project & configure my wcf library project to point to this new project, I'm finding that when i go and try to discover the service within my web application, I'm not seeing the design_time_address anymore. It's not discovering anything..
Here's what my app.config for the wcf service looked like before I moved the classes to a new project
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="Test.Server.Wcf.Service1">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8732/Design_Time_Addresses/Test.Server.Wcf/Service1/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address ="" binding="wsHttpBinding" contract="Test.Server.Wcf.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<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>
</behaviors>
</system.serviceModel>
</configuration>
and here's what it looks like after the move
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="Test.Server.Core.Service1">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8732/Design_Time_Addresses/Test.Server.Wcf/Service1/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address ="" binding="wsHttpBinding" contract="Test.Server.Core.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<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>
</behaviors>
</system.serviceModel>
</configuration>
What am I doing incorrectly? Any help would be greatly appreciated. I've been stuck on this for hours now and I feel like I'm losing my mind...
Thanks
The Discover option you use to add a service reference is an internal visual studio function. What is does is start and list the WCF services it can actually find an implementation for. For some reason it wants to find the implementation of the service interface in a WCF project type (library or application) with a config file. So if you moved you implementation to the Core project being a regular class library without app.config file, it will not Discover your service anymore.
What you can do is start your service manually and browser to the URL to add a service reference. It is just the discovery option that does not work anymore.