I have created a WCF service (DLL file), and I can use it when adding a service reference to it from my "adjacent" project in the solution.
I wish to make this WCF service accessible / host it, in a Windows Forms application. I need to use it from a remote location and need to access it via a URI. (IP address : Port !?)
What I am unsure of, is how to host it in the Windows Forms application? I have gone though many examples, but I can't quite get behind what needs to be done...
Do I add the DLL file reference to a new Windows Forms application, and somehow "shell" the DLL file?
Can I change my WCF service project type to a Windows Forms project? What needs to happen here?
I would appreciate some basic examples, that I could build upon. I have no preference for binding, but although I will now be accessing it from another remote Windows Forms application, ultimately, it will be accessed/used by a remote ASP.NET web application.
For now, I need to get it working on:
Remote Windows Forms application <---> (server) WCF service (hosted in its own Windows Forms application)
How can I do this?
If I understand correctly, rather that ASP.NET, it sounds like you are looking for self-hosting. See How to: Host a WCF Service in a Managed Application.
Your service can stay in its own class library; you only need to instantiate it from a Windows Forms project. For example, copy that Program.Main() into your Program.cs, replacing the...
Console.WriteLine("The service is ready at {0}", baseAddress);
Console.WriteLine("Press <Enter> to stop the service.");
Console.ReadLine();
...lines with the...
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
...ones typically included in a Windows Forms project.
Try this...
Add the DLL file reference of your already-created WCF library to the new Windows application project and on any event, like a button click, try the following code.
ServiceHost sh = new ServiceHost("http://localhost:9092/MyService")
sh.open();
You can refer to the article Four Steps to create first WCF Service: Beginners Series.
Related
I migrated my web app hosting a WCF Service from Windows 10 to Windows Server 2012. I followed the steps below:
Copied the folder where the Web App's files are to the new machine.
Installed all ASP.NET and WCF features.
Created a new application targeting the folder containing the files of the application.
When I try to run the service I get
HTTP 404 Error, The Resource cannot be found.
When I just target the svc file I get
Metadata publishing for this service is currently disabled.
I don't get this message when hitting the same URL in the original machine. Instead I get the regular screen telling me that I have created a service.
When hitting the root folder on a browser, in the original machine I get a white screen but in the new machine I get
A default document is not configured for the requested URL, and directory browsing is not enabled on the server.
As far as I can say, all configuration parameters are the same in both machines.
I want to add a detail that might help. When I restart the site on the original machine, the first time I request the service, I wait a few seconds for the site to compile and run. On the new machine this doesn't seem to happen. It may be that the code-behind is not loaded at all.
Please check if your IIS has svc handler added.
WCF services don’t run on IIS with the default configuration, because the webserver doesn’t know, how to handle incoming requests targeting .svc files. You can teach it in two steps:
Add a new MIME type:
Extension: .svc
MIME type: application/octet-stream
Add a new Managed HTTP Handler:
Request path: *.svc
Type: System.ServiceModel.Activation.HttpHandler
Name: svc-Integrated
Refresh your website/web application
References:
http://gyorgybalassy.wordpress.com/2012/09/24/publishing-a-wcf-service-on-iis8/
http://proq.blogspot.hk/2012/09/wcf-on-iis-and-windows-8.html
http://forums.iis.net/t/1200413.aspx?+svc+missing+can+t+find+Module+to+load+within+Handler+Mapping+IIS+8+0
Enable FTP Server from Control Panel->Programs and Features
http://www.kebabshopblues.co.uk/2013/09/20/hosting-a-wcf-service-library-project-in-iis-8-0-windows-8-0-net-4-5/
From Control Panel|Programs and Features, enable the following:
Internet Information Services (a number of contained items will be selected automatically, but not all, most notably the FTP Server);
‘HTTP Activation’ under ‘.Net Framework 4.5 Advanced Services | WCF
Services’ (there is a fairly similar option ‘Windows Communication
Foundation HTTP Activation’ under the ‘.Net Framework 3.5 (includes
.NET 2.0 and 3.0’ which I guess would be necessary if you were
targeting an earlier version of .Net);
There may be some features that support WCF that are not yet enabled in IIS. I have followed your steps to deploy the existed WCF service and consume the service successfully. Here are my features I have enabled in IIS.
Result.
Feel free to let me know if there is anything I can help with.
i'm building an Asp.Net app (contains the service) with Silverlight control (need to use the service) and having a problem after i discover the service and press OK button, can anyone help me please?
Try/Check the following:
Your service project is being properly build with no errors.
There is no other IIS / IIS express servers running in background.
Try to open the service address that you are trying to consume in the browser and see if it is loaded OK.
This should give you a lead on the problem.
I have Asp.Net solution that contains few WCF Service projects. Every time i run the application in debug mode, i can see that my services being hosted on ASP.Net Development Server. I just have single project in the start up.
Is there a way i can avoid this without removing these WCF Service projects from the solution?
To reproduce the situation. Create one ASP.Net project and add several WCF Service projects. Press F5 and you will see the WCF service projects being hosted on local development server.
This is what i have tried so far:
1) Project->Properties->Don't open a page. Wait for a request from an external application. I selected this option but it still hosts the service.
2) Unchecked ASP.NET in Debuggers selection. It still hosts the service.
Try right click the WCF project and go to the WCF Options tab.
Uncheck the Start WCF Service Host when debugging another project in same solution.
Is this what you are looking for:
I have zero knowledge on flex and need help to determine what is preventing my web service from being called.
We have a working application in production and the developer who wrote it has left.
I am trying to build it on my machine and I can see a web service call in fiddler being made with the URL "/Services.asmx/MethodName" (as a GET request).
I have set my break point in the asmx web service and it is not being hit. All I get in the flex front end is a pop up with " The remote server failed to respond and may be offline. http://MachineName/Services.asmx/MethodName"
The web service is in the same application as the web app that hosts the SWF file.
I have the cross domain policy file in place.
What I noticed in fiddler is the URL is "/Services.asmx/MethodName" and not "/WebApp/Services.asmx/MethodName" (not sure if this makes a difference) where WebApp is the IIS virtual directory to the web application that hosts the SWF.
Any ideas?
JD
If you are Web-services and your web-application is same domain then just pass the whole path like "http://..../Services.asmx" for creating web-service api instance in ActionScript 3.0 (for flex). and use this instance name to call your web-service method.
Please read this article from Adobe help for your perfect answer
I am developing one product and there are 4 separate projects, in that I have developed one EXE project and WCF and I have done switching in debugging mode by attaching WCF project in process of debugging client of EXE and it has worked.
But when I transfer my WCF to servicestack then I could not able switch between them.
I am running my EXE project and and attached my WCF(servicestack) project to process
JsonServiceClient client = new JsonServiceClient("MYServiceURL");
RESTWCF.ServiceModel.Perfmon objBalPerformanceDataProperties = MakeObjectForServiceStackToInsertData();
var res = client.Post<RESTWCF.ServiceModel.Perfmon>("/perfmon", objBalPerformanceDataProperties);
When I click F11 on client.post I could not able to switch in WCF project, I think you can make sense of my problem.
Give me some solution of this problem so I can debug my code of WCF project (to find error :) in that)
Thanks.
You can only debug one host project at a time.
If you want to test the server set the ServiceStack project to be Start-up Host and press F5 to start debugging the ServiceStack host. Put a break-point at the start of the service you want to hit.
You can then just Run (i.e. without debugging) the client application which if everything is configured correctly, it should hit your breakpoint.
To make sure you're debugging the service correctly, instead of running the client first try calling the web service via a url, e.g:
http://localhost/MyServiceUrl/perfmon
If it hits the break-point you set, then all is well and you can run the client application as mentioned above.
Also it's a good idea to include ServiceStack's debbuging symbols, i.e. it's *.pdb files in the same folder as it's *.dll's - as it helps with debugging.
Note: WCF has nothing to do with ServiceStack - In a lot of cases that's considered an insult :-)