IT박스

서비스 참조 오류 : 서비스 참조에 대한 코드를 생성하지 못했습니다.

itboxs 2020. 6. 30. 20:57
반응형

서비스 참조 오류 : 서비스 참조에 대한 코드를 생성하지 못했습니다.


Windows 서비스 솔루션이 있는데 VS2010의 Hermes (Opensource ebms 메시지 서버) 웹 서비스에 서비스 참조를 추가하려고합니다.

URL을 사용하여 웹 서비스를 찾을 수 있지만 서비스 참조를 채우려 고 시도하면 Visual Studio에서 다음 오류가 발생합니다.

Error 8 Custom tool error: Failed to generate code for the service reference 'testService'.  Please check other error and warning messages for details. C:\Users\Admin\documents\visual studio 2010\Projects\MyProject\MyProject.MessageHandler\Service References\testService\Reference.svcmap 1 1 MyProject.MessageHandler


Warning 6 Custom tool warning: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://service.ebms.edi.cecid.hku.hk/']/wsdl:portType[@name='EbmsStatusQuery']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://service.ebms.edi.cecid.hku.hk/']/wsdl:binding[@name='EbmsSoapHttpStatusQuery'] C:\Users\Admin\documents\visual studio 2010\Projects\MyProject\MyProject.MessageHandler\Service References\testService\Reference.svcmap 1 1 MyProject.MessageHandler

Warning 7 Custom tool warning: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='http://service.ebms.edi.cecid.hku.hk/']/wsdl:binding[@name='EbmsSoapHttpStatusQuery']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://service.ebms.edi.cecid.hku.hk/']/wsdl:service[@name='EbmsMessageStatusQuery']/wsdl:port[@name='EbmsStatusQuery'] C:\Users\Admin\documents\visual studio 2010\Projects\MyProject\MyProject.MessageHandler\Service References\testService\Reference.svcmap 1 1 MyProject.MessageHandler

Warning 5 Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.XmlSerializerMessageContractImporter
Error: Schema with target namespace 'http://service.ebms.edi.cecid.hku.hk/' could not be found.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://service.ebms.edi.cecid.hku.hk/']/wsdl:portType[@name='EbmsStatusQuery'] C:\Users\Admin\documents\visual studio 2010\Projects\MyProject\MyProject.MessageHandler\Service References\testService\Reference.svcmap 1 1 MyProject.MessageHandler

일부 조사에 따르면 svcutil.exe가 디렉토리에 대한 권한이 없기 때문에 (svc : c : \ windows \ temp) 프록시를 빌드 할 수 없었기 때문인 것으로 보입니다. 다양한 액세스 권한을 할당하려고 시도했지만 어떤 사용자에게 권한이 필요한지 또는 빨간색 청어인지 확실하지 않습니다.

어떤 아이디어라도 대단히 감사하겠습니다.

감사


서비스 참조 구성에서 참조 된 모든 어셈블리에서 유형 재사용 옵션을 선택 취소해야합니다.

자세한 내용은 이것을 확인하십시오


서비스 참조를 마우스 오른쪽 버튼으로 클릭하고 Configure Service Reference...

서비스 참조 구성

그런 다음 선택을 취소하십시오 Reuse types in referenced assemblies

재사용 유형

을 클릭 OK하고 솔루션을 정리하고 다시 빌드하십시오.


Visual Studio 2012를 사용하여 ASP .Net MVC 4.0 프로젝트에서 웹 서비스 용 클라이언트를 생성하려고 할 때도 비슷한 오류가 발생했습니다.

문제의 근본 원인은 클라이언트를 생성하려고 시도한 프로젝트가 어셈블리를 참조하고 있다는 것입니다.이 어셈블리는 참조되지 않은 다른 어셈블리에 의존합니다.

서비스 구성에서 "참조 어셈블리의 유형 재사용"이 활성화 된 경우 서비스 생성기는 재사용 가능한 유형 목록을 얻기 위해 참조 된 모든 어셈블리를 검사하고있을 것입니다. 참조 된 조립품 중 하나가 사용할 수없는 다른 조립품을 참조하고 있다는 사실은 아마도 발전기가 고장날 수 있습니다.

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.


http://uliasz.com/2011/06/wcf-custom-tool-error-failed-to-generate-code-for-the-service-reference/#comment-1647

Thanks to the article above.

In my case, i have this issue with my WPF project in VS.Net 2008. After going through this article, i was realizing that the assembly used in the web service is different version of assembly used on client.

It works just fine after updating the assembly on the client.


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.


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.


As stated above, there are a couple of different problems possible. What we found is that the .DLL for the WCF library had been added as a reference to the client project. This, in turn, created problems with resolving the objects and thus caused the files to be "emptied" by code generation steps. While unchecking the use "Reuse Types..." can seem like an answer, it creates extra definitions of object types, which are proxies to the real types, in a new name space, which then causes all kinds of "compatibility" issues with the use of those types. Only if you really want to "hide" a type should you check this option.

Hiding the type would be appropriate when you don't want a "DLL" type dependency to "leak" into a project that you are trying to keep segregated from another. If the DLL for the WCF library project creeps into the client project references, then you will have this problem with all kinds of strange side effects since the type definitions are also in the DLL.


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


I have encountered this problem when upgrading a VS2010 WCF+Silverlight solution in VS2015 Professional. Besides automatically upgrading from Silverlight 4 to Silverlight 5, the service reference reuse checkbox value was changed and generation failed.


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


I had this problem when trying to update my service reference (The error only shows up when adding a service reference though) but didn't want to remove the assembly reuse checkbox.

What worked for me was the following:

  • Remove referenced assembly that I wanted to re-use
  • Update service reference
    • Keep "Reuse types in specified referenced assemblies"
    • Ignore the errors, it's because the reference is missing!
  • Add reference to assembly again to fix the errors
  • Update service reference again

Voila, now it actually updates and doesn't try to remove all of my generated code anymore.

I was almost ready to give up on the re-use types feature...


어셈블리 재사용 확인란을 해제하지 않고이 문제를 해결하려면 다음과 같이하십시오.

  • 재사용하려는 참조 된 어셈블리 제거
  • 프로젝트의 모든 bin 폴더를 삭제하십시오.
  • 서비스 참조 업데이트
    • "지정된 참조 조립품에서 재사용 유형"유지
  • 오류를 수정하기 위해 어셈블리에 대한 참조를 다시 추가하십시오.
  • 서비스 참조를 다시 업데이트

Visual Studio를 다시 시작하면 속임수가되었습니다. VS 2015를 사용하고 있습니다.

참고 URL : https://stackoverflow.com/questions/3977560/service-reference-error-failed-to-generate-code-for-the-service-reference

반응형