HOw to manage newly added methods into WCF service - wcf

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

Related

Incorrect WCF Service Reference / Empty Reference.cs file

I have created a WCF service using Service Library template. Using the Service.dll generated, I have hosted the service in a console application.
However, when I add a Service Reference in my web project, on viewing the Service details in Object browser, it points to incorrect assembly in the object browser as shown in the screen shot below.
One possible issue could be that, while renaming the namespaces in my web project, I ended up renaming the namespace of Service project also. But even after fixing all the namespaces, I still have this issue.
Any ideas on what can be done to resolve it?
While adding a Service Reference, it displays the correct members/interfaces as shown in the screenshot below. Only when I view the Service Reference in the object browser, I don't see those interfaces exposed by the service.
Project dependencies of service project
Not sure why the web project is a dependency of the Service library project? It should not be as I have not added any reference to it in the Service project.
I came across this question here after researching on this issue.
I also found out that the reference.cs file was empty in my case also. After unchecking Reuse types in referenced assemblies from 'Configure Service Reference' dialog, I was able to generate the Service reference client code successfully. My Service reference is now pointing to the correct Interface/members. In case of any queries, feel free to comment or contact me directly.

Must I add a WCF service class library in order to host a WCF Service in a Windows service?

I read about how to host Wcf Service in a Windows service. There is a guide here:
http://msdn.microsoft.com/en-us/library/ms733069.aspx
But what I did was just to create new WCF Service class and interface inside the same project of the Windows Service instead of creating a new project separatly for the Wcf service.
Is it possible to do it? because I can't add a service reference to that service from other projects in the solution. It can't find it.
OK, here is what I found.
Creating a new solution with one Windows service project with a Wcf service class and one Asp.Net folder.
Running the Windows service.
Trying to add a Service reference to the Asp.Net project.
Result: Service can't be found.
Adding a new project which contains a Wcf project to the solution.
Adding a reference to it from the Windows Service.
Trying to add a Service reference to the Asp.Net project.
Result: Service found.
Reading this link:
http://msdn.microsoft.com/en-us/library/ms731758.aspx it's done similar to what I did in the test solution, but still there is a need to write some code in the Windows Service.
In this link:
http://msdn.microsoft.com/en-us/library/ms731758.aspx
They show how to host it without creating a separate project.
So the answer to the question is no, you must not, but you have to write some code for hosting the service and can't just use the configuration file.
Note the windows service must be running so you can successfully add the reference.

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

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

How to add a service reference to a WCF client for a web service requiring client authentication certificate

Caution, WCF noobie alert
I need to create a WCF client to query a non-WCF web service.
The web service is not a WCF service. Additionally, the web service requires a client authentication certificate. Now, I have the certificate, and can create a non-WCF client that works perfectly; I was able to 'Add Web Reference' and a certificate dialog box opened up to allow me to select the appropriate certificate, then went on to create the web reference. Trying to create a WCF client via 'Add Service Reference' is another story, it just fails with a 403 Access Denied error.
I have the WSDL for the service, and have run svcutil.exe on it, but am not sure how to proceed from there.
Thanks for any help!
I'm assuming that the service you are using is performing client SSL authentication.
Since add service reference is failing, you can use svcutil to generate the client from the WSDL file that you have. I think the syntax would be something like:
svcutil *.wsdl /l:C# /out:Reference.cs /config /s /ct:System.Collections.Generic.List`1 /ser:Auto /tcv:Version35 /n:*,<NameOfYourNamespaceHere> /edb
This will generate a file, Reference.cs, that contains the proxy classes to the service (you can give this file whatever name you want). Add this file to your project. A config file, output.config, will also be generated. You can add this configuration to your application configuration instead of typing it all in by hand.
Now you can follow this MSDN article on using Transport Security with Certificate Authentication. You can skip down to the client section where it shows how to attach the certificate to the request in code as well as in configuration.
I know this is the old question and it has been already solved but I would like to mention that Add service reference also works for WSDL files stored on disk. Marc has also mentioned it. Add service reference dialog accepts:
URL to WSDL
URL to Metadata exchange endpoint
Service URL where /mex is added internally
Any file path to WSDL file
So if you have WSDL and all need XSD files you can use Add service reference as well. The only tricky part is that Add service reference dialog doesn't have Browse button and that is the reason why this functionality is not well known.
Stupid question (maybe): could you connect to the service endpoint, present it with your credentials stored in the certificate, and then download the WSDL (and possibly XSD) from there? Or could it be the entity offering this service would be able to actually send you these files (or make them available for download)?
Once you have the WSDL (and XSD) file on disk, it should be easy enough to create WCF client for that (using either svcutil.exe or Add Service Reference) based on those files, and then configure the appropriate security for it.
Just a thought.... (worth $0.02?)
Marc
OK, bit of a work-around here (and I've no idea what is going on technically): I noticed that when you add a Web Reference, the certificate you have chosen is cached and automatically used the next time you add the Web Reference (I noticed because I'd chosen the wrong certificate). This caching seems to work across Web Reference and Service Reference so:
Add a Web Reference to the endpoint, choosing the certificate you wish to use
Remove this Web Reference
Add a Service Reference to the same endpoint and Visual Studio will use the same certificate you chose for the Web Reference
Worked on Visual Studio Community 2019, v16.7.7

How to use a WSDL File to create a WCF Proxy?

I have an old WSDL file and I want to use WCF to communicate with the service.
The WSDL is generated from a ASMX (I suppose but I am not sure).
What would be the required steps to communicate with it ?
Right-click your project, and choose "Add Service Reference". Point to the WSDL. Click "Ok". That should be all.
Use svcutil.exe to create a WCF proxy to call the service. Details here.
wsdl.exe is the old web service (1.1) way of creating a proxy. The first thing to try is "Add Service Reference" as already mentioned. This uses svcutil.exe to create the proxy. If you need more control over how the proxy is created, you can use svcutil.exe from the command line with a variety of switches.
With that said... I have had trouble with older web service wsdls. In particular, an old Apache AXIS Web Service containing overloaded operations. Please see my post here for complete details. (My problem still isn't solved. I hope you don't encounter the same issues, but if you do and figure them out, please answer my question. :)