Service Reference Error: Failed to generate code for the service reference

后端 未结 13 1883
囚心锁ツ
囚心锁ツ 2020-11-30 19:07

I have a Windows Service Solution and am trying to add a service reference to a Hermes(Opensource ebms message server) Web Service in VS2010.

I can find the Web Serv

相关标签:
13条回答
  • 2020-11-30 19:28

    Restarting Visual Studio did the trick for me. I am using VS 2015.

    0 讨论(0)
  • 2020-11-30 19:30

    "Reuse types" is not always the problem when this error occurs.

    When adding a reference to an older service, click 'advanced' and there 'Add Web Reference'. Now link to your wsdl and everything should be working.

    0 讨论(0)
  • 2020-11-30 19:32

    It would be extremely difficult to guess the problem since it is due to a an error in the WSDL and without examining the WSDL, I cannot comment much more. So if you can share your WSDL, please do so.

    All I can say is that there seems to be a missing schema in the WSDL (with the target namespace 'http://service.ebms.edi.cecid.hku.hk/'). I know about issues and different handling of the schema when include instructions are ignored.

    Generally I have found Microsoft's implementation of web services pretty good so I think the web service is sending back dodgy WSDL.

    0 讨论(0)
  • 2020-11-30 19:32

    I get the same error in Silverlight 5 (VS2012)

    You can also remove the references to:

    • System.ServiceModel.DomainServices.Client
    • System.ServiceModel.DomainServices.Client.Web

    After you've updated the service references, be sure to add them back in.

    0 讨论(0)
  • 2020-11-30 19:33

    face same issue, resolved by running Visual Studio in Admin mode

    0 讨论(0)
  • 2020-11-30 19:36

    I also encountered a similar error when trying to generate the client for a web service from an ASP .Net MVC 4.0 project using Visual Studio 2012.

    The root of the problem seems to be that fact that the project from where I was trying to generate the client was referencing an assembly which in turn was dependent on another assembly that was not being referenced as well.

    When "Reuse types in referenced assemblies" is enabled in the service configuration, the service generator is probably inspecting all the referenced assemblies to get a list of types that can be reused. The fact that one of the referenced assemblies is referencing another assembly which is not available is probably causing the generator to fail.

    Unchecking "Reuse types in referenced assemblies" from the service configurations will solve the above problem, but there is a side effect to it. The reuse types option is there for a reason and in some cases it avoids unnecessary casting in the code consuming the service.

    For example, if the service itself is built using WCF and some methods parameters inside it are of type System.Guid, they will be translated to strings in the generated client if the reuse types option is disabled.

    An alternative that I prefer to disabling reusing types is to add the service reference from Class Library project specifically created for that purpose. The one thing to keep in mind is to copy all the service related configurations from the class library's app.config to the configuration file of the startup project.

    If there are types defined in local assemblies that need to be reused in the service client, those assemblies simply need to be referenced from the above mentioned class library project, along with all their dependencies.

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