13

I have an existing project that consumes web services. One was added as a service reference, and the other as a web reference. I don't recall why one was added as a web reference, but perhaps it's because I couldn't get it to work!

The existing service reference for the one web service works fine, so it's not a .net version issue.

I can successfully create a service reference for the second web service, but none of the methods are available. The .wsdl shows the schema, but the Reference.vb shows only the Namespace, and none of the methods.

To clarify, these are two different 3rd party web service providers.

We'd like to move to the service reference so we have more control over the configuration as we're having various issues with timeouts.

Anyone come across this before?

Edit

Does it matter that there are two services at the address?

Edit

I'm using .net 3.5 and VS2008.

alt text http://img139.imageshack.us/img139/719/addservicereference.gif

ScottE
  • 21,530
  • 18
  • 94
  • 131

5 Answers5

10

The Add Service Reference feature is notoriously a pig and is buggy - I use it most of the time, but occasionally I hit problems where the code it generates is either like this (i.e. non-existent) or it doesn't reuse types where it should do.

You should try using the svcutil command line tool (open a VS Command Prompt to run it), which although it is similar to the reference feature of VS is actually a completely different codebase. You can use that to generate a proxy, all the client-side types etc, just as with the service reference feature.

Most importantly - it seems to work nearly all the time - so long as the service itself is sane.

Andras Zoltan
  • 41,961
  • 13
  • 104
  • 160
1

What exactly do you mean when you say, "the methods are not available"?

Many people who say things like that are expecting the methods to be available in exactly the same way as they were with "Add Web Reference". But they're different. See "How to Consume a Web Service".

John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • John, if you read above you'll see that I'm already consuming one of the 3rd party web services successfully, and it was added as a service reference. The other I can add successfully, but there are no methods available under the namespace (intellisense or object browsing). It does work just fine when added as a web reference, however. – ScottE Mar 13 '10 at 20:48
  • @ScottE: thanks for clarifying. I suggest you run svcutil from the command line to have it try to generate proxy classes. The benefit would be that if there were any errors, they would be displayed. You can also look in the reference.cs file to see if there are comments indicating problems in generating code, or you might notice a pattern in terms of what's present and what's absent. – John Saunders Mar 14 '10 at 01:17
  • the reference.cs file is empty. I'll try the command line and see what happens. Thanks. – ScottE Mar 14 '10 at 01:32
  • John - using svcutil did the trick. It wasn't part of your answer, so I couldn't mark your answer as correct. Thanks for the input. – ScottE Mar 17 '10 at 12:32
  • @ScottE: If svcutil worked without error, but "Add Service Reference" failed so badly, then please do us all a favor and report this on Connect (http://connect.microsoft.com/visualstudio/). Once reported, post the Bug Report URL in your Question so we can vote on how important this is. I believe this is the first time I've heard of the two methods not being nearly equivalent. – John Saunders Mar 17 '10 at 13:54
  • @John - I'll do that once I get a moment - just back from vacation. Thanks. – ScottE Mar 18 '10 at 11:15
0

Although an old post, but just want to share my experience so that it might help some one today.

When communicating with Web services developed on platform such as Java, Phython or Ruby probably the cause of Stub/Proxy classes not being generated due to compliance issues (WS-I interoperability standard). You might encounter errors such as:

Failed to generate code for the service reference ServiceReferenceName. Please check other error and warning messages for details...

The actual error details you can get by using svcutil.exe of course in which case the error might look something like:

Error: Cannot import wsdl:portType

Its better to go with Web Service Reference for such services rather than Service Reference. (Add Service Reference -> Advanced -> Add Web Reference...)

In case you are enthusiast about playing with XML & WSDL you might go ahead and fix the issue with binding & portType. Probably the imports & include need to be corrected if i remember correctly from last time i wasted time fixing it to make it work with Service Reference Option.

Mobiletainment
  • 22,201
  • 9
  • 82
  • 98
Shoaib Khan
  • 899
  • 14
  • 26
0

I suspect it is trying to re-use the types from the other reference. Click Advanced... and remove the "re-use types in referenced assemblies" box. You should also ensure that the service name is unique, to avoid conflicts.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • Nope, that's not it. I tried adding the service reference to a new web app project as well. Have you successfully added a service reference to a wsdl that has more than one endpoint available, via the add service reference wizard? Or, like John has recommended, does this need to be done via the command line? – ScottE Mar 14 '10 at 12:26
0

Have you tried to add the reference to a C# project instead of a VB.NET one?

I noticed all the methods on your service are named "getXXX", maybe it's clashing with some "intelligent" processing on the VB.NET generator.

Try creating a new C# project and adding the service reference.

Fábio Batista
  • 25,002
  • 3
  • 56
  • 68
  • Seems like a shot in the dark as the 'add web reference' worked fine in vb.net, but I'll give it a try. – ScottE Mar 16 '10 at 21:57