How to generate a wsdl file of a wcf service library project? - wcf

I have a few Wcf service library projects (not Wcf service application) in my solution. I have to give the .wsdl files of the projects to my collegue who will consume the services.
How can I do that?
Thanks in advance,

You can use the WCF Service Host to start a new instance of your service, and then add ?wsdl to the service address to access the wsdl (http://localhost:1234/MyService.svc?wsdl for instance).
WcfSvcHost's syntax is the following:
WcfSvcHost.exe /service:<PathToServiceDLL> /config:<PathToServiceConfig>

Follow these steps:
Go to IIS add new application under the default web site.(alias:test
physicalPath: c:\test), dont press test connection
On your wcf project right click and run publish choose your new
application on IIS.
Goto IIS to test application, right click on the svc file and browse - its open IE.
On the url address on the IE add to the address ?wsdl. and ENTER it.
good luck

Related

Deploying WCF Library

I am sorry in advance for the question because it should be so easy for someone who has web programming experience, but for me ...
I have created a WCF library which gets an email address, subject and body and sends email using a gmail account. I do not know how I can deploy it.
I already published it on my host using visual studio but don't know what URL should I use to call it. Can I use it directly or I have to create a WCFapplication and add the service to it then publish the WCF app?
Also, I noticed the base address in its config file is sth like: localhost/emailservice/service1 and I am not sure if I should edit it or not and how.
Your help is greatly appreciated.
Since you created a WCF library, I am assuming that you are open to host it as an IIS application or as a windows service.
Assuming that you wish to host your library as an IIS application, follow the steps mentioned in this blog to host your WCF service library.
Please note: If you intended to host your service as an IIS application, it would have been far easier for you to create a WCF service application project in Visual Studio instead of a WCF service library project.

HOw to manage newly added methods into WCF service

I have created wcf service and added its refernece into web application project.
Have added as below way: 1. generated proxy and config file using - svcutil command and added proxy file into web application project and merged configuraiton file.
Now, I have added some new methodsinto the wcf service , do i have to use - SVCUTIL command on each time or it should work automatically.... for now, i need to generate proxy file each time.. please suggest some best way.
NOTE: service instance available into ASP.NET web applicaiton (client) but unable to get when use client as - MVC applicatoion. please suggest.
Thanks
In the Web Application, open the Service References folder.
Right click on the Service you want to update.
Select Update.
Thanks for the response.
I found the answer, when add service reference (for MVC application) >>> click at 'Advance' button >>> uncheck the "reuse object....." option and then add it.
Then, service client reference is available and it works.
Just for KS, sharing you another design issue due to Add Service Reference option at below link:
What should keep into this design approach
Thank You

Questions about adding a WCF service to a Windows service assembly

I have found some basic information about hosting a WCF service in a Windows service, but not much. All of my experience thus far with WCF has been in Web projects. I have a few simple questions.
I have a project which creates a windows service application. I have done a right click -> add WCF Service. This creates Service1.cs and IService1.cs.
I'm wondering why no SVC file is created in this scenario? When I add services to Web projects i get an SVC file which I can navigate to and use to consume the service.
Adding the service adds some configurations to the app.config under the services element. I'm seeing a default base address of
http://localhost:8732/Design_Time_Addresses/WindowsServiceName.services/WCFServiceName/
What does this mean? It's sort of an odd looking address. Am I supposed to change it to whatever I want?
Navigating to this address in a browser results in an unable to connect message. Does the windows service itself have to be running to talk to the WCF service?
How do I go about consuming this service from another application without an svc file?
I'm taking a guess on this first one, but I'm thinking the .svc file when hosting in IIS is to tell IIS, "Hey I have a WCF service here, please handle accordingly".
The base address is as it should be and yes you can change it if I'm not mistaken.
You can't hit the WCF service unless the Windows service is running, which is one of the dangers of hosting in a Windows service, because if the service dies somehow your WCF service is offline until you get the Windows service running again.
You consume the service the same way you do any other WCF service, just using that base address to get at it.

How to configure the wcf service to view the test page without pointing to svc file in address box?

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.

How to call local WCF service from webpage?

I'm developing a webpage that is supposed to consume WCF webserice that is located on client's computer. First, user installs some software that hosts WCF service on his computer, then he'll view my webpage which is supposed to call the WCF service. Do you have any idea how to do it without having to use AtiveX and IE?
Add your wcf service as service reference to your web project. You have to specify the url of your wcf service. A clientproxyclass will be generated for you. In your webpages or whathever you can create a instance of this proxyclass and just code what you want.