views:

570

answers:

4

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

+1  A: 

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
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
@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
the reference.cs file is empty. I'll try the command line and see what happens. Thanks.
ScottE
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
@Scott: what was the error?
John Saunders
There wasn't an error - svcutil worked fine.
ScottE
@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
@John - I'll do that once I get a moment - just back from vacation. Thanks.
ScottE
A: 

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
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
A: 

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
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
Yep, didn't work.
ScottE
+3  A: 

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