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
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'm new to WCF. I created WCF method that returns file. I deployed it to azure App Service and it worked when i called it like this
https://myapp.azurewebsites.net/myService.svc/MyMethod?MyParam=MyValue
Than i turned on Azure active directory authentication for azure App Service and now i get 404 error. But authentication against AAD works - i get redirected to login page if i'm not singed in user.
I tried searching SO and google and i can't figure out what i'm doing wrong or if it is just not possible to set up this way with WCF.
Web config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
</appSettings>
<system.web>
<customErrors mode="Off"/>
<compilation targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5.2"/>
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
</httpModules>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<webHttpBinding>
<binding name="ServiceWebBindingName" transferMode="Streamed" maxReceivedMessageSize="2147483647" >
<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" />
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="DefaultRestServiceBehavior">
<webHttp defaultOutgoingResponseFormat="Json" defaultBodyStyle="Wrapped" automaticFormatSelectionEnabled="false"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="My.App.Service">
<endpoint address="myService.svc"
binding="webHttpBinding"
bindingConfiguration="ServiceWebBindingName"
behaviorConfiguration="DefaultRestServiceBehavior"
name="FileManagerServiceEndpoint"
contract="My.App.IService"/>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="ApplicationInsightsWebTracking"/>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"
preCondition="managedHandler"/>
</modules>
<!--
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="false"/>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
</configuration>
So i found out i did not notice, that my original service url was
http://myapp.azurewebsites.net/myService.svc/MyMethod?MyParam=MyValue
and one that i was redirected to after adding azure ad authentication was
https://myapp.azurewebsites.net/myService.svc/MyMethod?MyParam=MyValue
So redirect points to HTTPS and not HTTP.
It is probably possible to set azure ad application not enforce HTTPS traffic, however in spirit of security and to avoid possible IE zone switching issues I added HTTPS transport to my WCF binding in web.config. Here is great example how to do it How to enable HTTPS on WCF RESTful Service? and it now works flawlessly.
I read much about my problem but i can't find solution. When I go to controller with my service compiler returns:
There was no endpoint listening at {0} that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
InnerException:
Basic connection was closed: An unexpected error occurred when receiving
I try with mex and close my firewall, when I start app my service works correctly (I can visit localhost:52093/AccountService.svc) but when I go to controller to invoke service IIS stops working.
My web.config:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IAccountService" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:52093/AccountService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAccountService"
contract="AccountService.IAccountService" name="BasicHttpBinding_IAccountService" />
</client>
</system.serviceModel>
Any ideas?
Thanks in advance
E:
My Service config
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1"/>
</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"/>
<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>
You seem to be missing the <service /> and <endpoint /> tags. Refer to this MSDN article on how to properly setup your Web.config for hosing your WCF service on IIS.
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.
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