1

I successfully added a WCF Service Reference to my ASP.NET project, but I'm not able to use it.
I can't import the service referenece via using MyProject.MyService.

This worked in a standard Windows Form project and I now, that the requested service is working.

Thanks for your help.

Edit: There occure Warnings during the generation of the service client
I think the "main" warning is the following

Warning 1   Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension:System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Type 'Newtonsoft.Json.Linq.JToken' is a recursive collection data contract which is not supported. Consider modifying the definition of collection 'Newtonsoft.Json.Linq.JToken' to remove references to itself.

This warning comes only at the generation in an ASP.NET project. The generation works in my other projects.

It seems that this is a problem of a class I'm not responsible for. May I have to change the settings for the service reference creation or avoid some imports in the original WCF Service class?

Cybermaxs
  • 24,378
  • 8
  • 83
  • 112
Lennart
  • 73
  • 3
  • 11
  • Did you change the name of the service reference? If not, the default reference would be something like ServiceReference.MyService – Dave Aug 29 '12 at 09:06
  • you can click on show all files in solution explorer, go to service reference deep down until you will find Reference.cs and check there namespace. – Giedrius Aug 29 '12 at 09:07
  • Yes I changed it. I tried to import MyProject.MyServiceReference and then to use the services in the service reference. – Lennart Aug 29 '12 at 09:09

1 Answers1

1

We need some more information in order to troubleshoot this for you. Is the reference being added but you cannot use it?

I would suggest looking at the reference.cs file (under the service reference, you may need to tell solution explorer to show all files - little icon of the folders and files at the top) and seeing what namespace it has been generated with.

I think you're probably just not using the correct namespace to reference the client.

The other possibility: check for any compiler warnings, they might give you a clue as to what is going on.

EDIT: This seems to be an issue encountered by others. Do you have the json.net package installed?

Please see the following for details:

Getting "Recursive collection data contract" when referencing a WCF service with a slightly complex method

Community
  • 1
  • 1
Sam Shiles
  • 10,529
  • 9
  • 60
  • 72
  • The service Reference is added and listed in the _Service References_ of my project. I can't find any namespace in the reference.cs file. Shall I change this to the namespace of the project? Edit: I just saw that there is no code in the reference.cs – Lennart Aug 29 '12 at 09:13
  • That's the problem then, it sounds like svcutil.exe has failed to generate the service client. Delete the reference, add it again, and check the output (you may have to change the source), to check for any errors or warnings being generated by svcutil. If you can't see anything you may want to consider running svcutil.exe from the command line with verbose logging enabled. See: http://msdn.microsoft.com/en-us/library/aa347733.aspx – Sam Shiles Aug 29 '12 at 09:24
  • I tried to recreate the reference and there were several errors during the code generation. They are to long to post them in a comment so I edited the question. – Lennart Aug 29 '12 at 09:35
  • Yes the answer was to except the Newtonsoft.JSON from "reuse types in referenced assemblies" when adding the service reference to the project. See [linkt](http://nirlevy.blogspot.co.il/2012/08/cannot-import-wsdl-porttypedetail.html) for more information. Thanks Sam – Lennart Aug 29 '12 at 11:00