I have a WCF service that I would like to host in IIS 7.5. My setup:
The physical path of the folder with .svc file is: C:\inetpub\wwwroot\SmartSolution\Services\Services\ContainerManagementService.svc
My binaries are in C:\inetpub\wwwroot\SmartSolution\Services\bin
I have created a web application in IIS for both Services folders.
Here is the config file for the WCF endpoint:
<service behaviorConfiguration="MyNamespace.ContainerManagementServiceBehavior"
name="MyNamespace.ContainerManagementService">
<endpoint address="" binding="basicHttpBinding"
name="ContainerManagementbasicHttpEndpoint" contract="MyNamespace.IContainer"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
<behaviors>
<behavior name="MyNamespace.ContainerManagementServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</behaviors>
Here is my .svc file makrkup:
<%# ServiceHost Language="C#" Debug="true" Service="MyNamespace.ContainerManagementService" CodeBehind="ContainerManagementService.svc.cs" %>
When I try to navigate to: http://localhost/SmartSolution/Services/Services/ContainerManagementService.svc , the following error is displayed:
The type 'MyNamespace.ContainerManagementService', provided as the Service attribute value in the ServiceHost directive could not be found.
How can I get the service to work. Thanks!
IIS is expecting your bin folder to be in the same folder as your .svc file, but it appears that you have it placed in the parent folder.
Also, you should only need the one application specified in IIS.
If your site is precompiled and you already have the binaries (containing the MyNamespace.ContainerManagementService) in the bin folder you don't need to specify a CodeBehind attribute:
<%# ServiceHost
Language="C#"
Debug="true"
Service="MyNamespace.ContainerManagementService"
%>
If on the other hand your site is not precompiled and you have shipped the source code as well this source code need to be in the special ~/App_Code folder.
Related
I was given just a folder with an .asmx and previously compiled /bin folder with DLLs. I'm trying to run this web service on my local machine but I'm getting an error.
So far I did the following:
Installed IIS
Created an application 'myWebService' under 'default web site' in IIS
Pointed to the c:\inetpub\wwwroot\myWebService
when I browse to http://localhost/myWebService
HTTP Error 404.3 - Not Found The page you are requesting cannot be
served because of the extension configuration. If the page is a
script, add a handler. If the file should be downloaded, add a MIME
map
As far as I know, the 404.3 error means there is no handler which could handle the asmx file when the request comes to the IIS.
I suggest you could firstly check you have the webservicehanlderfactory in your application's handler mapping.
If there is no such handler mapping, I suggest you could try below solution to install it.
For the server:
Go to Server Manager > Add roles and features Select your server from the server pool Go to Features > WCF Services I selected all categories then installed
For the Windows10:
Open the control panel > Windows features > Select the IIS >World wide web service and enable below settings:
Besides, if you want to host the asmx on the IIS, you should also have the right web.config file.
I suggest you could ask the provider to get the config file. If you don't get it, you couldn't run the web service well.
Web.config example:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.8" />
<httpRuntime targetFramework="4.8"/>
</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>
I created a RESFTful WCF web service and i installed it in IIS as a new web application. The WCF has some actions like: Login, getEmployees ...etc. and it works fine when i publish and run it from vs, so i can reach from browser links like:
http://myserver/service.svc
http://myserver/service.svc?wsdl
http://myserver/Login?user=sample&password=paswd
http://myserver/getEmployees?name=dada
and with the action links i get the exact needed data as a response.
however it works only when i run the web service from vs, but when i try to reach the links from browser and the web service is NOT running in VS i can reach only links like:
http://myserver/service.svc
http://myserver/service.svc?wsdl
but not the operational links like:
http://myserver/Login?user=sample&password=paswd
http://myserver/getEmployees?name=dada
Endpoints configurations:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings/>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<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="AXPAYROLL.PayrollActions" behaviorConfiguration="serviceBehavior">
<endpoint address="http://myserver/" behaviorConfiguration="RESTFriendly" binding="webHttpBinding" contract="AXPAYROLL.IPayrollActions">
<identity>
<dns value="myserver" />
</identity>
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://myserver/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="RESTFriendly">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<!-- 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" />
<serviceAuthorization serviceAuthorizationManagerType="AXPAYROLL.DataContractLayer.DistributorValidator, AXPAYROLL" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
I also created a console host application where everything worked just fine like from vs, so the problem in IIS for sure may be in permissions...
I am new in WCF but i believe that it can't be the right way to run vs always to get the wcf deployed!!! i also want to install the wcf on a productive server where no vs is installed, i know that the self hosting could be achieved with the console application but this is again not what i want, i want it torun over normal iis,any idea what is the problem? did i miss something?
When the WCF service on IIS, any base address specified in the <baseAddresses> will be ignored and the base address will be the URL to the .svc file.
The address attribute in the endpoint element is a relative address and could be like address="rest".
So in IIS, the url will be http://myserver/service.svc/rest/getEmployees?name=dada
Update:
To remove svc extension, have a look at this question
I am working on a Web Service app. The tools in use for this project are a Windows Server 2012 Standard and Visual Studio Pro 2013. App is in C#, .NET 4.5
At this early point in the development of this app., it's in the proof of concept stage. No database, nothing fancy at all; trying to get the basic architecture to work. Running in the development environment, everything works fine. Publishing to the server does not work. I get 404 - File or directory not found when I try to open this page in a browser. On my development system/personal web server, I can see the results of the app running on the page displayed.
I have looked at a number of tutorials and step-by-step instructions on how to do this. This and this was very helpful.
After some work on the server side, I got the web deploy feature to work from my development system to the server. I have also tried other install techniques.
I have reached a wall in narrowing down the problem because I don't know IIS architecture all that well and that seems to be the problem, unless I have misunderstood some aspect of running my test/proof of concept. I have not gotten much help from my service provider running the server debugging this.
Any thoughts on how to narrow this problem; where to look, alternative tests to try, much appreciated.
web.config (this is the generic version generated by
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="false" />
</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.Service1">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8371/Design_Time_Addresses/Test/Service1/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="basicHttpBinding" contract="Test.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 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>
</system.serviceModel>
</configuration>
adding this to the config solved the problem.
<system.webServer>
<handlers>
<add name="svc-Integrated" path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" resourceType="File" requireAccess="Script" preCondition="integratedMode" />
</handlers>
</system.webServer>
In my ASP.NET WebForms project I have a reference to the WCF services library project, which contains different WCF services for each business object. The services are hosted in IIS and it's possible to get WSDL via routes I defined in the Global.asax: one WSDL via one route for each service.
What I really need - some ability to choose services what I want to provide for different customers and generate a SINGLE WSDL for the chosen services set.
Yes its possible to configure WCF routing service and get WSDL files form individual service behind it.
Step 1 - Set HttpGetEnabled set to true and configure MEX Endpoint in all WCF Service those are behind your router service
<service behaviorConfiguration="routingBehv" name="System.ServiceModel.Routing.RoutingService">
<host>
<baseAddresses>
<add baseAddress="http://localhost/WcfRoutingService/RoutingService.svc"/>
</baseAddresses>
</host>
<endpoint address="http://localhost/WcfRoutingService/RoutingService.svc" binding="mexHttpBinding" name="mexEndpoint" contract="System.ServiceModel.Routing.IRequestReplyRouter"/>
</service>
Step 2- Configure Routing Service
Add Endpoint
<endpoint address="" binding="mexHttpBinding" name="mexEndpoint" contract="System.ServiceModel.Routing.IRequestReplyRouter"/>
Add service behaviour
<behaviors>
<serviceBehaviors>
<behavior>
<routing routeOnHeadersOnly="false" filterTableName="routingTable" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="false" />
</behavior>
</serviceBehaviors>
</behaviors>
Client Endpoint address should specify the "MEX" endpoint address
<client>
<endpoint address="http://localhost/PremiumWcfService/PremiumWCFService.svc/mex" binding="mexHttpBinding" contract="*" name="PremiumServiceMex"/>
<endpoint address="http://localhost/StandardWCFService/StandardWCFService.svc/mex" binding="mexHttpBinding" contract="*" name="StandardServiceMex"/>
</client>
Specify the routing table
<routing>
<filters>
<filter name="StandardServiceMexFilter" filterType="EndpointAddress" filterData="http://tempuri.org/WcfRoutingService/RoutingService.svc/StandardService" />
<filter name="PremiumServiceMexFilter" filterType="EndpointAddress" filterData="http://tempuri.org/WcfRoutingService/RoutingService.svc/sPreminuService" />
</filters>
<filterTables>
<filterTable name="routingTable">
<add filterName="StandardServiceMexFilter" endpointName="StandardServiceMex"/>
<add filterName="PremiumServiceMexFilter" endpointName="PremiumServiceMex"/>
</filterTable>
</filterTables>
</routing>
You are all done.
You can directly access the WSDL file of your services by below URLS individually :
http://localhost/WcfRoutingService/RoutingService.svc/StandardService
http://localhost/WcfRoutingService/RoutingService.svc/PremiumService
the problem in your solution is : you give to your clients a WSDL with the address of your web service PremiumWCFService and StandardService , and the clients (WCF) can use that directly without check and can call your web sevices without call routing service.
I created web service library like in this link http://www.codeproject.com/Articles/167159/How-to-create-a-JSON-WCF-RESTful-Service-in-60-sec
To publish it I followed the link http://naztek.wordpress.com/2009/08/27/host-a-wcf-library-in-iis/
but I got this error at run time
Server Error in '/WCFService1' Application.
The type 'Service', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element
system.serviceModel/serviceHostingEnvironment/serviceActivations could
not be found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The type 'Service', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
My web.config is :
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
<services>
<service name="test1.Try">
<endpoint address="http://localhost:8732/Try" binding="webHttpBinding" contract="test1.Try"/>
</service>
</services>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
[InvalidOperationException: The type 'Service', provided as the Service attribute value in the ServiceHost directive, or provided in
the configuration element
system.serviceModel/serviceHostingEnvironment/serviceActivations could
not be found.]
It looks to me like You missed Step 3 from the second link (about publishing). Especially this part:
Change the Service attribute value from Service to the fully qualified name of the concrete class in our WCF library, e.g., RegistrationServiceLib.RegistrationService
To open svc file use right click -> open with -> XML (text) editor
You should see something like this:
<%# ServiceHost Language="C#" Debug="true" Service="YourNamespace.Service" CodeBehind="Service.svc.cs" %>
Change this to match your service (just like your tutorial stated).