问题
I have a solution that is on TFS. I'm trying to add a WSDL as service reference to it.
The WSDL's URL looks like this: ".../ws/soap;auth=..."
When adding the reference, VS will generate all the required xsd files and the xsd files name would use the URL as its name. When generating it, TFS will try to automatically add the files, and at this point it will detect that I have a .xsd files with illegal character ";" as its name and then the whole service reference generation just failed and stopped.
I have tried adding the wsdl to a solution that is not bound to TFS and it works just fine.
Any workaround? How do I add the wsdl as service reference to my solution if the generated xsd contains illegal character that TFS won't accept?
回答1:
You can use svcutil to generate proxy classes,svcutil is a .NET tool that retrieves metadata from a web service on a network location or from a WSDL file, and generates a WCF class containing client proxy methods that access the web service operations.
You can use this tool on the command-line interface of VS: enter image description here
Executing the above command will generate the a proxy class and configuration file on disk D.Then add these two files to your project: enter image description here
Here's a link about svcutil:
https://docs.microsoft.com/en-us/dotnet/core/additional-tools/dotnet-svcutil-guide?tabs=dotnetsvcutil2x
回答2:
Can you try adding a new class to your project, and copy the contents from the generated proxy class file through svcutil (link below, just in case). This way, I believe, you would be able to bypass the illegal characters in XSD.
You would be able to generate proxy class through Visual Studio Command Prompt using SvcUtil command
HTH!
来源:https://stackoverflow.com/questions/61631400/adding-wsdl-service-reference-to-vs-fail-because-generated-xsd-file-contains-ill