Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.net web service: Can't add service reference, only web reference

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

like image 260
ScottE Avatar asked Mar 04 '10 15:03

ScottE


People also ask

How do I add a Web reference to a SVC file?

Try starting your service first by right-clicking the . svc file and using "View in Browser". Then give the URL of the service to the "Add Web Reference" dialog.

How do I add a Web service reference in .NET Core?

NET Core or . NET Standard project, this option is available when you right-click on the Dependencies node of the project in Solution Explorer and choose Manage Connected Services.) On the Connected Services page, select Add Service Reference.

What is difference between Web reference and service reference?

The service reference is the newer interface for adding references to all manner of WCF services (they may not be web services) whereas Web reference is specifically concerned with ASMX web references. You can access web references via the advanced options in add service reference (if I recall correctly).


2 Answers

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.

like image 85
Andras Zoltan Avatar answered Sep 23 '22 03:09

Andras Zoltan


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".

like image 44
John Saunders Avatar answered Sep 23 '22 03:09

John Saunders