开发者

.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 th开发者_开发百科is 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


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.


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


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜