I inherited some code which included a service reference. I realized that the server the reference pointed was removed. I still have the code which included an .svc file. I guess that must be a WCF kind of a service, and I need to restore it on another server, but I have no idea how to do that.
As I said, the code includes an svc file, and also Web.config, Web.Debug.config, Web.Release.config, a project file, and some source files.
Updated question with web.config
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" >
<serviceActivations>
<add relativeAddress="ExcelConversionService.svc"
service="MyDomain.FileServices.ExcelConversionService"/>
</serviceActivations>
</serviceHostingEnvironment>
You can host this service in IIS. please look at the following MSDN references
http://msdn.microsoft.com/en-us/library/aa751792.aspx
http://msdn.microsoft.com/en-us/library/ms734710.aspx
A more hands-on example is available at
http://www.codeproject.com/Articles/150066/Create-Host-Self-Hosting-IIS-hosting-and-Consume-W
Related
I have a Silverlight application that communicates to a WCF service. As part of the web.config file there is a required section to use WCF:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Upon deployment to a Windows 2008 server I get the following error when launching my Silverlight app:
Parser Error Message: It is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level. This error can be
caused by a virtual directory not being configured as an application in IIS.
Source Error:
Line 29:
Line 30: <system.serviceModel>
Line 31: <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
Line 32: multipleSiteBindingsEnabled="true" />
Line 33: </system.serviceModel>
After some research there are a couple of items that could cause this:
The directory where the app resides is not setup as an application in IIS
Multiple web.config files exist in one or more sub-directories underneath the application structure.
Neither of these situations apply in my case. My app is setup as an application under IIS and there is only one web.config file in the application structure.
Any other reasons this message would occur? It also happens if I explicitly define the authentication type in the web.config file for the app.
Thanks for your help.
In addition, for me to make it work, I had
... CodeBehind="mypage.aspx.vb" inherits="Account5.mypage"
and I changed it to
... CodeFile="mypage.aspx.vb" inherits="mypage"
I hope this helps someone else.
I'm using an encrypted timestamp to secure communications between a WCF service in my web server and another in the 'mid-tier'. In the calling service (the client in this exchange) I'm using a DLL whose class inherits System.ServiceModel.Configuration.BehaviorExtensionElement to provide functionality implementing System.ServiceModel.Description.IEndpointBehavior and System.ServiceModel.Dispatcher.IClientMessageInspector. This is glued in via the web.config file with the sections
<extensions>
<behaviorExtensions>
<add name="MessageInspectorBehavior" type="MessageInspectorDLL.MessageInspectorBehaviorExtensionElement, MessageInspectorDLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</behaviorExtensions>
</extensions>
<endpointBehaviors>
<behavior name="MessageInspectorEndpointBehavior">
<MessageInspectorBehavior />
</behavior>
</endpointBehaviors>
and then these are hooked up to the mid-tier WCF with entries like this one
<client>
<endpoint address="http://blah.cloudapp.net:8080/BlahService.svc"
behaviorConfiguration="MessageInspectorEndpointBehavior" binding="customBinding"
bindingConfiguration="CustomBinding_BlahService"
contract="BlahServiceReference.BlahService"
name="CustomBinding_BlahService" />
In the mid-tier there's a similar story with a System.ServiceModel.Dispatcher.IClientMessageInspector decrypting the time stamp and either processing the request or throwing a System.ServiceModel.FaultException with the error message "Invalid stamp".
This follows code examples at http://msdn.microsoft.com/en-us/library/ms733747.aspx and http://weblogs.asp.net/paolopia/archive/2007/08/23/writing-a-wcf-message-inspector.aspx
Now I have changed the mid-tier WCF. Some changes are simple (e.g. correcting a spelling mistake in a method name "retrive" -> "retrieve") while some adds more substantial functionality and I want to update the service recerences in the client. In VS2010 I right-click on the service references that will need updating and select "Update Service Reference". VS2010 connects to the mid-tier WCF ("downloading service information") and then throws the error
The configuration for the service reference could not be updated due to the following issue: The type 'MessageInspectorDLL.MessageInspectorExtensionElement, MessageInspectorDLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' registered for extension 'MessageInspectorBehavior' could not be loaded. (C:\TFS\Blah\Blah\web.config line 80)
What's wrong? Is there something I need to set up for the update service reference to correctly use the message inspector DLL?
Though it is possible that the DLL or the web.config have errors that seems unlikely since the client will connect to the previous mid-tier which is up on Azure, and that has the same encrypted timestamp inspection.
I've found an answer. Adding the MessageInspectorDLL as a reference to the ASP application fixed it for me.
I'm not sure if this problem is specific to Accelerator for Web roles (WAAWR: http://waawebroles.codeplex.com/)
Edit: I have confirmed this error is only thrown in my WAAWR application - if I deploy the same code as a stand alone webrole this error is not thrown.
I'm trying to run WCF Routing / clean urls on an application that is being deployed via WAAWR. This feature requires asp .net compatibility mode. Here is my config section:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://api.mydomain.com"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
I've been stuck on this error for a couple of hours:
System.IO.FileLoadException: Filename:
\?\C:\Resources\directory\XXXXXXXXXXXXXXXXXXXXXXX\web.config
Line number: 74 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". at
Microsoft.Web.Administration.Interop.IAppHostAdminManager.GetAdminSection(String
bstrSectionName, String bstrPath) at
Microsoft.Web.Administration.WebConfigurationManager.GetSectionInternal(String
siteName, String virtualPath, String sectionPath, Type sectionType)
At first I thought that the apps you deploy via the web role host were sub-directories/virtual directories, so I threw this config into the .config file of the deploy host application itself - but that didn't do the trick. I remote desktop-ed in to see what's going on and it looks like each application deployed via the host is it's own application under IIS in its own right. Also when you explore the app from IIS manager, the apps aren't event located on the same drive as the deploy host. So I'm not sure why this error is being thrown.
Any ideas out there?
Found my answer here:
http://cennest.wordpress.com/2010/09/20/azure-tip-wcf-4-0-servicerouting-in-azure/
Not sure why it works find with a normal role & you have to add the section declaration for an child application - but happy it's working!
My WCF service exposes an https AND an http endpoint. Apart from the SSL they are identical. They map to the same code.
The ultimate intention is for external users to connect via https, internal users to use http.
In development this gives me a problem. Cassini, the development web server packaged in VS, hates SSL.
I'm wondering if I can configure the service from code, so when running under Cassini, I would not configure https.
Hence the question - How do I configure the service from code if it is IIS hosted? I'd be very happy with alternative answers on how I can persuade Cassini to NOT complain about the https part of the configuration.
"IIS will take care of spinning up the necessary ServiceHost based on your *.svc file - not a whole lot you can do about that, really."
Not too close to the truth. Exactly in the SVC file of your service there is attribute named Factory. Where you can specify the the class and the assebly where the class is located. This class may be your own descendant of Web|DataServiceHostFactory
So your svc markup would look like this
<%# ServiceHost
Language="C#"
Debug="true"
Service="name.space.myService"
CodeBehind="name.space.myService.svc.sc"
Factory = "name.space.WebServiceHostFactoryEx, assembly.name"
%>
The WebServiceHostFactory will be created for every service hit and will recreate your host the way you want it.
You will also need to inherith WebServiceHost and create it the way you need it with certain endpoins, behaviors, addresses, etc settings - whatever you like.
There is very nice post from Michele Bustamante here
EDIT: I figured out the above link is not working anymore, so here it is another one.
I am using this in IIS hosted enviroment for couple of services that are initialized same way.
When you're hosting in IIS, you're leaving a lot of care taking into the realm of IIS - you cannot really grab a hold of your service in this case.
IIS will take care of spinning up the necessary ServiceHost based on your *.svc file - not a whole lot you can do about that, really.
My solution would be different - externalize the <service> tag in your configuration file (web.config):
<system.serviceModel>
<services>
<service configSource="service.dev.config" />
</services>
</system.serviceModel>
In your dev environment, only expose the http endpoint - so your service.dev.config would look something like this:
<service name=".....">
<endpoint name="default"
address="....."
binding="basicHttpBinding" bindingConfiguration="insecure"
contract="......" />
</service>
Create a second service.prod.config which then contains both endpoints - http and https:
<service name=".....">
<endpoint name="default"
address="....."
binding="basicHttpBinding" bindingConfiguration="insecure"
contract="......" />
<endpoint name="secure"
address="....."
binding="basicHttpBinding" bindingConfiguration="secure"
contract="......" />
</service>
and reference that in your web.config on the deployment server.
I have been testing out the new WCF fileless activation stuff in .net 4 that allows you to use config rather than having a physical svc file.
The relevant part of my web.config looks like this:
<serviceHostingEnvironment>
<serviceActivations>
<add relativeAddress="Service1.svc" service="WcfService1.Service1" factory="WcfService1.UnityServiceHostFactory" />
</serviceActivations>
</serviceHostingEnvironment>
This runs ok but if I add any breakpoints, they do not get hit. When using svc files, they have debug="true" in the markup but I do not know how to allow this when doing it through config.
Any ideas?
Oops. It seems as though I was mistaken. After being called on to something else for a while, I have revisited this code and it appears to be working normally. The debug flag in normal svc files doesn't actual do anything.