I have a WCF service developed on .NET framework 4. My dev machine is running Windows 8, Visual Studio 2012 and I already published the service at IIS 8.
Now I need to publish the service on a Windows XP machine. I'm getting several errors on IIS 5.1, so I gave up to use this version and I'm trying to use IIS Express 7.5 with VS2010.
The service gets up with no problems, but I cant acess the WSDL cause it says that metadata is disabled.
What can I do to activate metadata on my WCF service?
Follows the web.config:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="SAP.Middleware.Connector">
<sectionGroup name="ClientSettings">
<section name="DestinationConfiguration" type="SAP.Middleware.Connector.RfcDestinationConfiguration, sapnco"/>
</sectionGroup>
</sectionGroup>
</configSections>
<SAP.Middleware.Connector>
<ClientSettings>
<DestinationConfiguration>
<destinations>
<add NAME="XXX" USER="XXX" PASSWD="XXX" CLIENT="XXX" LANG="EN" ASHOST="mc0.sap.XXX.com" SYSNR="XXX" MAX_POOL_SIZE="XXX" IDLE_TIMEOUT="XXX"/>
<add NAME="QA" USER="XXX" PASSWD="XXX" CLIENT="XXX" LANG="EN" ASHOST="XXX" SYSNR="XXX" MAX_POOL_SIZE="XXX" IDLE_TIMEOUT="100"/>
</destinations>
</DestinationConfiguration>
</ClientSettings>
</SAP.Middleware.Connector>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<appSettings/>
<system.web>
<compilation targetFramework="4.0" debug="true"/>
<httpRuntime/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" 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>
You should check if in your config file that you enable mex.
e.g. (mex though http).
In your service behavior you should enable the following option
<serviceMetadata httpGetEnabled="true" />
In your endpoint list you should add the following
<endpoint address="/mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
Save your config and rerun.
I found this topic wich instructs to use WEBMATRIX to host a WCF application in IIS Express. It worked perfectly for me.
Hope it can help somone else!
http://blogs.iis.net/vaidyg/archive/2010/07/29/serving-external-traffic-with-webmatrix-beta.aspx
Related
I am creating WCF web service. So i got an example in Github. Project Example
I am able to compile the project. But i am getting System.IO.DirectoryNotFoundException error.
My URL is: http://127.0.0.1:8080/v1/HelloService.svc/
My IDE: Visual Studio 2019 MAC
web.xml
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
<serviceActivations>
<add relativeAddress="v1/HelloService.svc"
service="FilelessActivation.Services.HelloServiceImpl"
factory="System.ServiceModel.Activation.ServiceHostFactory" />
</serviceActivations>
</serviceHostingEnvironment>
<services>
<service name="FilelessActivation.Services.HelloServiceImpl">
<endpoint binding="basicHttpBinding"
bindingNamespace="http://oscarkuo.com/v1/hello"
contract="FilelessActivation.Services.IHelloService" />
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
The root cause is that we have to enable Windows feature to support SVC extension in IIS. Subsequently, we could have this service working.
Besides, please note, In the WCF project, No need SVC file doesn’t represent that the relative address in the ServiceActivations doesn’t contain SVC extension.
Result.
Related links.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/configuration-based-activation-in-iis-and-was
Feel free to let me know if the problem still exists.
I have a C# WCF web service that I setup on WS2008R2 and it works fine. I go into IIS and right-click JobService.svc, it opens up a browser and puts in a URL:
http://1.2.3.4/WebServices_DEV/JobService.svc
and the service shows. Absolutely fantastic!
However, I have a WS2012 server and I try to do the same.
If I open up IIS and right click on JobService.svc, it opens a browser and puts in the URL correctly.
However, it shows:
<%# ServiceHost Language="C#" Debug="true" Service="WebService.JobService" CodeBehind="JobService.svc.cs" %>
Now my web.config shows like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<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" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<security>
<requestFiltering>
<requestLimits>
<headerLimits>
<add header="Content-type" sizeLimit="100000" />
</headerLimits>
</requestLimits>
</requestFiltering>
</security>
<directoryBrowse enabled="true" />
</system.webServer>
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information" propagateActivity="true">
<listeners>
<add name="ServiceModelTraceListener" type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" initializeData="wcf-traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
I don't know whether it's that I am relying on not specifying end points or bindings so I add them in:
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="JobService" />
</webHttpEndpoint>
</standardEndpoints>
<bindings>
<basicHttpBinding>
<binding name="JobService" />
</basicHttpBinding>
</bindings>
But it has no effect.
What I am I doing wrong please.
Thanks.
It seems that IIS is missing handler mappings or Http Activation for WCF Services is disabled. Here is instruction how to fix it: IIS 8 missing handlers
Following link can also help: IIS Hosted Service Fails
Maybe this is a solution
First make sure you install the necessary feature about wcf in the windows feature.
You can check all about IIS, and all about .Net Framework 3.5, 4.5
and maybe tou should add the MIME type:
mimeMap fileExtension=".svc" mimeType="application/octet-stream"
add Service.svc to your default document
and run the site, I Success run the service.svc
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” />
Below is the default layout for the web.config of a new WCF Service Application in VS2012.
What confuses me is that it doesn't seem to match any examples or tutorials online. There are no endpoints or bindings defined, yet it's possible to call the service.
I hit a problem when trying to increase the MaxReceivedMessageSize property - I googled it and didn't have a clue where to look in my web.config.
Can someone point me in the right direction of why it's so strangely laid out?
I expected it to look more like This SO question about setting MaxReceivedMessageSize or even any WCF tutorials like Michelle Bustamante's which is how I originally learned WCF.
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" 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>
Starting with .NET 4.0, WCF introduced the concepts of default endpoints and bindings, allowing developers to create a service without having to define a bunch of stuff in the configuration file.
The posted config file is targeting 4.5, which is why you're seeing such a naked WCF config. If you need to increase your maxMessageSize, you'll need to explicitly define it in the config.
You can do this by either setting that binding definition as the default (by omitting the name attribute on the binding element), or creating an endpoint and explicitly assigning the binding configuration you defined via the bindingConfig attribute.
See A Developer's Introduction to Windows Communication Foundation 4.
You can also check a previous answer by me that has examples: https://stackoverflow.com/a/16099054/745969
I made a 'Hello World' WCF service. The service doesn't have a svc file.
Therefore the web.config file determines its address and other settings.
However, I'm stuck with opening the specific page.
When I run the WCF service project, it always shows the error page (HTTP Error 403.14).
This is because the browser tries to go to localhost instead of localhost/HelloWorldService.svc.
Do you know how can I solve it?
I want to open the localhost/HelloWorldService.svc when I start running the WCF service in VS 2012.
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
<a href="http://go.microsoft.com/fwlink/?LinkId=169433">http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment >
<serviceActivations>
<add factory="System.ServiceModel.Activation.ServiceHostFactory"
relativeAddress="HelloWorldService.svc"
service="HelloWorldService.HelloWorldService"/>
</serviceActivations>
</serviceHostingEnvironment>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Go to Properties -> Web -> click Specific Page and enter /HelloWorldService.svc.