I have a WCF service that I am deploying in a shared hosting environment. Because of this I have to specify baseAddressPrefixFilters (see answer here for why this is necessary). Setting the base address prefix filters happens in the web.config like so...
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://example.com"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
The problem is that I have multiple environments that are configured this way with their own urls (i.e. dev, test, prod)
I tried the following with no luck...
<serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://dev.example.com"/>
<add prefix="http://test.example.com"/>
<add prefix="http://example.com"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
So the question is how do I set the baseAddressPrefixFilter dynamically at runtime?
If you are running under IIS7, this is a good walk through of the problem and solution. If not, the information for the WCF side is still what you need to know to resolve your issues.
http://keithelder.net/2008/04/28/configuring-wcf-and-iis-7-with-http-bindings-and-multiple/
Have you looked at the ServiceHostFactory? We used this in our 3.0 services to work with the different host headers.
http://blogs.msdn.com/rampo/archive/2007/06/15/supporting-multiple-iis-bindings-per-site.aspx
Related
I have this WCF service that works fine using soap1. I'm trying to change it to run in soap1.2 but I have not been able.
I have try changing different things in the webconfig.
First, I change the basicHttpBinding for wsHttpBinding. I also change the protocol, remove the soap1.1 and add the soap 1.2
How I can make that my WCF web service run in soap1.2?
Some code that I try in the config file:
<webServices>
<protocols>
<add name="HttpSoap" />
<add name="HttpSoap12" />
</protocols>
</webServices>
<protocolMapping>
<remove scheme="http" />
<add scheme="http" binding="wsHttpBinding" />
</protocolMapping>
The problem was not the project. I was using Soap UI to call the service. I did know that I have to modify the Soup UI WS-Addressing setting for it to work. I set the Must understand option to true and check the add default wsa To: option. With that the service works fine using soup ui
I'm working on implementing OpenID based single sign-on using ServiceStack.Authentication.OpenId. and have run into an annoyance that I want to solve. For development I would like to be able to test on my local machine without having to self-sign a certificate and change my hosts file. This way I can easily distribute the code to our other developers without needing to include a set of instructions for how to get it working on a local machine.
We are using DotNetOpenAuth as the provider, which actually allows this by itself by configuring it with:
<dotNetOpenAuth>
<relyingParty>
<security requireSsl="false" />
<behaviors>
<!-- The following OPTIONAL behavior allows RPs to use SREG only, but be compatible
with OPs that use Attribute Exchange (in various formats). -->
<add type="DotNetOpenAuth.OpenId.Behaviors.AXFetchAsSregTransform, DotNetOpenAuth" />
</behaviors>
</relyingParty>
</openid>
<messaging>
<untrustedWebRequest>
<whitelistHosts>
<!-- since this is a sample, and will often be used with localhost -->
<add name="localhost" />
</whitelistHosts>
</untrustedWebRequest>
</messaging>
However I have not yet found a way to utilize a similar setup through ServiceStack. Is anyone able to shed insight on how to set this up? The error I currently get when attempting to use it in this manner is as follows:
The URL 'http://localhost:8080/OpenId' is rated unsafe and cannot be requested this way.
I have developed a .NET REST web service in C#. While I have plenty of C# experience, I unfortunately do not have much understanding in deploying such a service in a web hosting environment.
Due to the environment, I do NOT have access to IIS.
The advice I have been provided with by the support services of the hosting provider is as follows:
Create a subdomain of the main domain to achieve a dedicated application pool (this a requirement of the host provider)
Create a Bin folder to hold my compiled libraries of source code
Add the following to the Web.Config file:
<system.web>
<httpHandlers>
<add type="ReportRESTWebService.Service, ReportRESTWebService" verb="*" path="report" />
</httpHandlers>
</system.web>
<system.webServer>
<handlers>
<add name="report" path="report" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="File" requireAccess="Script" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
</handlers>
<directoryBrowse enabled="false" />
</system.webServer>
The above would have the effect of creating a handler mapping for the report resource on all HTTP verbs and forwarding any HTTP traffic on that resource to my ReportRESTWebService.dll for handling.
The point I am unclear on is whether the above will be satisfactory and how do I test whether the advice I am given is correct. I know that I have the site running locally but I have access to IIS so I have control over the configuration.
Hopefully somebody can help.
Thanks
If you are using Wcf Rest,then you can probably consider hosting it as as windows service
or self hosted service.
Windows Service
http://blogs.msdn.com/b/juveriak/archive/2009/03/15/rest-endpoint-hosted-in-a-wcf-windows-service.aspx
Self hosted Service
http://www.c-sharpcorner.com/uploadfile/dhananjaycoder/self-hosted-wcf-rest-service-or-hosting-wcf-rest-service-in-console-application/
It would seem, after a day of exhaustive testing, that the steps I had taken (detailed in the question) would be satisfactory.
One point to watch out for is the matching Managed Pipeline Mode for your application pool. Failure to match this up correctly with your Web.Config will result in pain.
we have built a asp.net web service application that we test on the local machine.
We have deployed it on the client's server and tested it there as well.
The web service returns JSON data, not xml.
But when the we try to access that URL from a remote machine, we cannot see the input fields for taking the parameters. it shows the list of the methods in the web service but when we click on them there's no text fields for input.
We'd like to access the web services remotely and test them.
Any help would be appreciated.
You'll want to make sure you have the following in your config file.
<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
Really though you should probably be using something like SoapUI for testing services as the tests are re-runnable ect.
I have a Visual Studio 2010 solution with 2 projects. One is a Silverlight client, the other a web site to which I added a domain service. It works fine when debugging in Cassini, but when I publish to IIS I get nothing returned from my entity query.
I'm not even sure where to start as this is my first attempt at doing this.
A few things:
Developing on Cassini (don't do it if you can avoid it)
It's always better to develop against IIS itself. There are differences between IIS and Cassini which can bite you if you aren't aware of them and it just makes more sense; you should always develop as close to the environment that you are develping for. Unless you are deploying to Cassini (and you aren't, no one does) then there's no point in developing against it unless you simply can't (you don't have a local install of IIS).
Web Deploy
Install Web Deploy on the IIS server you are going to deploy to. Once you do that, you can right click the web/domain project in your solution and select "Build Deployment Package".
Then, you will get a package that you can use with Web Deploy which will deploy everything (Silverlight, ASP.NET components, etc, etc) your project to IIS with a simple command-line call.
This was a very stupid, newbie issue. I used SQL Server Profiler to watch the queries come in and realized the account being used to authenticate against SQL Server was the server's computer account. I secured the Domain Service's methods and allowed the computer account access tot he DB.
Deploying to IIS might have some issues. I'd like to see what errors messages you're getting. Without these information it will become pretty difficult to give you an advice.
PS: I'm gonna assume that your WCF RIA services have valid definition ;-).
Based on my experience, this is the minimum config file, but it certainly will require more settings if you're consuming Authentication Domain Services or Data domain services (such as LinqToEntities or LinqToSql domain services):
Make sure your IIS have all the sections required by WCF RIA
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.serviceModel">
<section name="domainServices" type="System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" allowDefinition="MachineToApplication" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web>
<!-- You might need identify tag if you app requires additional permission to run -->
<!-- See you want to see more details when a error happens -->
<customErrors mode="Off"/>
<compilation debug="true" targetFramework="4.0" />
<!-- If your application uses authentication and authoriztion then -->
<!-- Elements required required for authentication: authentication and membership and probably roleManager -->
<httpModules>
<add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<add name="DomainServiceModule" preCondition="managedHandler"
type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</modules>
</system.webServer>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
Make sure the WCF RIA services are up and runnning
Try to access the WCF RIA service by using a web browser. Usually the service you're exposing has format like:
http://[hostname]/[namespacename]-[classname].svc
So, you should be able to hit the URL and see an output like:
Make sure DLLS are available
There are two options to deploy the WCF RIA dlls in the server side. You can indicate to the application that DLLs should be copied into the bin folder of your application or you can run the WCF RIA installer in server mode.
Accessing the services from the client
If the services are up and running they should be reachable to your Silverlight client. If there is an error you can start tracing by enabling WCF RIA debugging.
See http://blogs.msdn.com/b/saurabh/archive/2010/03/16/ria-services-application-deployment.aspx for more details about it.