Add service link does not create proxy server

I understand that there are other similar questions, but I could not find a working answer.

I create the default WCF service from the template [which comes with GetData () and GetDataUsingDataContract ()]. A.
It works fine in the browser.

I have a separate website to which I am adding this new WCF service:

I do "Add a link to a service", enter your URL, a service will appear and click "OK" to add it.
In the "App_WebReferences" section, I see the namespace of my added service: "ServiceReference1", under it "References.svcmap" and a couple of .svcinfo / .wsdl / .xsd files.

No proxy files are created, but the <system.serviceModel> element has been added to my web.config so that it seems to be the correct information.

However, without a proxy server, I cannot access / call any methods in my service (i.e. ServiceReference1.WCFMethod1() )

I can call svcutil, generate a proxy, add it to my App_Code, and everything will work as it should. My question is: why my proxy is not created using the "Add service link"?
Everything is in the target environment: .NET Framework 4.

EDIT:

Just created a console application and added a link to the service, and she created a proxy. So the problem is that my website is not creating a proxy server ...

+7
source share
3 answers

I had the same problem, and it turned out that fixing the problem with reuse types in all reference assemblers . However, in my case, I needed it to reuse types from some of my referenced libraries. I found this post covering a very similar issue. In this article, he refers to a Microsoft Knowledge Base article that describes a fix for the following problem:

Consider the following scenario:

  • You are creating an ASP.NET MVC4 web API project in Visual Studio 2012.
  • A WCF service link is added to the project.

In this case, the Reference.cs file for the service link is empty.

Cause

This problem occurs because the DataContractSerializer class has detected a type ( Newtonsoft.Json.Linq.JToken ) that it does not support. In this case, it throws an exception and then stops generating a service link.

I did not reference this JSON library, but based on this error description, I assumed that one of my referenced libraries should have had a similar problem. I believed that one of the libraries I referenced probably contained a type that was not supported by DataContractSerializer , it threw the same exception, and therefore it failed in the same way.

Of course, I found out that in my case the culprit was one of my own libraries, which included a public proxy for the same WCF service. I suspect it was a public proxy that was causing problems. In any case, by selecting Reuse Types in the referenced assemblies , and then selecting all the assemblies, in addition, the service link automatically generated proxy classes correctly.

+3
source

When you add ServiceReference: Links β†’ Add a new service link. Clik on the extended button and uncheck "Reuse types in all reference assemblies." This parameter sometimes causes errors.

+2
source

That is the main question. The source of the problem is when you cannot find Add a web link in your visual studio. If the service is asmx, in my case it did not create a proxy class until I find these steps β†’ click on the Sercice link β†’ Click on β€œAdvanced” β†’ There you will see "Add web link ...". the problem is resolved. Hope this helps.

+2
source

All Articles