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

后端 未结 5 1193
无人及你
无人及你 2020-12-30 06:26

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 ref

相关标签:
5条回答
  • 2020-12-30 06:44

    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 讨论(0)
  • 2020-12-30 06:46

    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.

    0 讨论(0)
  • 2020-12-30 06:51

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

    0 讨论(0)
  • 2020-12-30 07:02

    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.

    0 讨论(0)
  • 2020-12-30 07:09

    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.

    0 讨论(0)
提交回复
热议问题