Wcf 获得';没有生成代码';尝试使用svcuti.EXE创建web服务代理时出错

Wcf 获得';没有生成代码';尝试使用svcuti.EXE创建web服务代理时出错,wcf,wcf-client,Wcf,Wcf Client,当尝试使用svcuti.EXE(在命令行上或通过Visual Studio)创建web服务代理(WCF)时,我会收到以下无意义的错误消息 注意:这项服务没有问题,因为它可以在另一台机器上正常工作。这是新安装的Windows,服务在我的本地邮箱中。使用不同机器上的URL在我的机器上生成相同的代理可以正常工作 怎么回事 Microsoft (R) Service Model Metadata Tool [Microsoft (R) Windows (R) Communication Foundati

当尝试使用
svcuti.EXE
(在命令行上或通过Visual Studio)创建web服务代理(WCF)时,我会收到以下无意义的错误消息

注意:这项服务没有问题,因为它可以在另一台机器上正常工作。这是新安装的Windows,服务在我的本地邮箱中。使用不同机器上的URL在我的机器上生成相同的代理可以正常工作

怎么回事

Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.1]
Copyright (c) Microsoft Corporation.  All rights reserved.

Attempting to download metadata from 'https://ws1.example.com/ShoppingCartWS/WCF/ShoppingCartWCF.svc?wsdl' using WS-Metadata Exchan
Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageCont
Error: Schema with target namespace '' could not be found.
XPath to Error Source: //wsdl:definitions[@targetNamespace='']/wsdl:portType[@name='IShoppingCart']


Error: 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='']/wsdl:portType[@name='IShoppingCart']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='WSHttpBinding_IShoppingCart']   

.....    

Error: 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='']/wsdl:portType[@name='IShoppingCart']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='BasicHttpBinding_IShoppingCart1']


Error: 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://tempuri.org/']/wsdl:binding[@name='BasicHttpBinding_IShoppingCart1']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:service[@name='ShoppingCartWCF']/wsdl:port[@name='BasicHttpBinding_IShoppingCart1']


Generating files...
Warning: No code was generated.
If you were trying to generate a client, this could be because the metadata documents did not contain any valid contracts or services
or because all contracts/services were discovered to exist in /reference assemblies. Verify that you passed all the metadata documents to the tool.

Warning: If you would like to generate data contracts from schemas make sure to use the /dataContractOnly option.

警告:未生成任何代码
错误消息可能是由于缺少对
C:\Windows\Temp
目录上的应用程序池用户的权限而触发的(确实是!)

如果您遇到此错误,我首先建议您在尝试使用“添加服务引用”对话框时切换到命令行。在为服务URL打开Fiddler的情况下运行此命令

 svcutil.exe https://dev.example.com/ShoppingCartWS/WCF/ShoppingCartWCF.svc?wsdl
如果您看到任何请求返回为500(红色)和以下响应,那么您可能遇到了与我相同的问题

ReadResponse() failed: The server did not return a response for this request.                                                                            
只需选中
C:\Windows\Temp
,然后添加您的应用程序池正在运行的任何用户即可获得权限。我刚刚作弊并添加了
所有人
,但是如果安全性很重要,你应该从IIS中找到正确的应用程序池用户名


.

您的答案不只是解释了
警告:没有生成代码。
?这是如何解决您遇到的错误的?