I have published a WCF service in IIS however when I run the code (browse the site from within Iis) I just get the following line displayed in the browser.
<%# ServiceHost Language="C#" Debug="true" Service=......."
Any ideas why this is showing?
This was because the WCF features were not all enabled on the server.
Related
I have deployed an asp.net mvc application in IIS, The application has been deployed successfully and working fine. I Used ajax enabled wcf service in my application, the problem is when I want to use the method of the service. I get the not found error, but when I browse to see the service it gives the page saying that your service is hosted, I cannot access the methods of the deployed ajax enabled service.. Kindly help me out..
Things to be noticed..
My services are hosted as a file with the extension of .svc
I deployed the application on windows server 2008 r2 64 bit, but I configured the application pool to work in 32 bit.
Services are accessible, but the methods of service are not allowed.
Thanks in advance.
Ahsan Nomani.
I'm playing around with Castle WCF integration facility because I want to integrate my WCF services with windsor IOC.
The issue I'm facing is that I can't set IKernel for DefaultServiceHostFactory.
I setup the container:
container = new WindsorContainer().AddFacility<WcfFacility>();
container.Register(Component.For<DefaultServiceHostFactory>());
container.Register(Component.For<IFoo>().ImplementedBy<Foo>());
Then I setup the SVC file:
<%# ServiceHost
Language="C#"
Debug="true"
Service="Foo"
Factory="Castle.Facilities.WcfIntegration.DefaultServiceHostFactory, Castle.Facilities.WcfIntegration"%>
When WCF tries to instantiate DefaultServiceHostFactory it says kernell is null and recommends using DefaultServiceHostFactory.RegisterContainer(IKernel kernel) method. However this method is not available in latest version of WCF facility.
Any help appriceated!
Thanks
figured it out, I was deploying the application to windows Azure and I used the web role startup for container registration (WRONG!) once I putted the container setup into Global.asax file it started working for IIS and Azure emulator as well.
I have created a working wcf service. I have come a cross a page regarding wcf services
which describes the process for eliminating default wcf service page.
It is here https://github.com/geersch/WcfServiceMessage
Except for the things the author of this page is describing, I have one question.
How has he managed to configure the IIS or Web.config to host page with the address: http://localhost:8732/HelloWorld/ ?
At home, the only address I see my service at is: http://localhost:8732/MyServiceName.svc
(with svc extension)
How has he done it that the endpoint address: "HellowWorld" is used?
Thanks!
The WCF service endpoint is not actually a file. The total url itself is what the server recognizes as something to service, so the HelloWorld piece is just as good as HelloWorld.svc.
This is a difference between IIS hosted service and Windows or Visual Studio service host (cassini). In iis, you do have to specify a file that ends with svc and make that extension known. In iis you can also set a svc file as the default file to open if a specific directory is opened. that way you can achieve the same behavior.
My app has to be installed on my client's webservers. Some clients want to use SSL and some do not. My app has a WCF service and I currently have to go into the web.config for each install and switch the security mode from <security mode="Transport"> to <security mode="TransportCredentialOnly"> depending on the client's SSL situation. I am able to set the client bindings at runtime. However, I would like to know if there is a way to set the service bindings at runtime(on the server side).
Yes, absolutely! It depends on how you're hosting your WCF services. Saying it has to be installed on the webservers, I would assume you're hosting in IIS.
In that case, you need to create your own descendant of ServiceHostFactory - which really isn't that big a deal.
Your CustomServiceHostFactory is needed to return an instance of your ServiceHost, properly configured to your needs, to IIS.
In the CreateServiceHost method of the custom factory, you basically set up your ServiceHost and configure all its endpoints, behaviors, bindings, etc. - all in code, all under your full control. You can do whatever you need to do here, to configure your service just as needed.
In order to host your service. You'll need to adapt the MyService.svc file to include that CustomServiceHostFactory as the factory to use:
<% # ServiceHost Language="C#" Service="YourService"
Factory="CustomServiceHostFactory" %>
and that's it!
Check out Extending Hosting Using ServiceHostFactory on MSDN for more details, and see the A Custom ServiceHostFactory article on CodeProject for a sample.
My WCF service exposes this function
public SerialNumberInfo GetSerialNumberInfo(string serialNumber) { }
Is there a way to enable HTTP GET on my WCF service? Example:
http://localhost:8004/MyService/GetSerialNumberInfo?serialNumber=4
yes, you need to use the webHttpBinding on your WCF service.
See the WCF REST Starter Kit for more information on REST Support in WCF.
REST in WCF
Overview of REST in WCF
Series of screencasts on how to use REST in WCF
If you're hosting your service in IIS, you need to create a separate *.svc file for the REST service (let's call it RESTService.svc), which contains:
<%# ServiceHost Service="YourServiceName" Language="C#" debug="False"
Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>
Now you should be able to connect to the URL
http://localhost:8004/MyService/RESTService.svc
and get your data RESTfully.
Marc
What you want to do sounds like building a RESTful service with WCF. Check out the following article on MSDN, it has all the details:
A Guide to Designing and Building RESTful Web Services with WCF 3.5