简体   繁体   English

由于大量服务操作而导致添加服务引用时出错

[英]Error on adding Service Reference due to an amount of service operations

I have a service contract with a sufficient amount of operations (~ 40 operations). 我有一份服务合同,有足够的操作(约40次操作)。 When I'm trying to add Service Reference from my client project (or even from WCF Test Client ) I'm getting an error: 当我尝试从我的客户端项目(甚至从WCF测试客户端 )添加服务引用时,我收到一个错误:

Error: Cannot obtain Metadata from net.tcp://localhost:12345/DataProvider/mex If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. 错误:无法从net.tcp获取元数据:// localhost:12345 / DataProvider / mex如果这是您有权访问的Windows(R)Communication Foundation服务,请检查您是否已在指定地址启用元数据发布。 For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: net.tcp://localhost:12345/DataProvider/mex Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:12345/DataProvider/mex'. 有关启用元数据发布的帮助,请参阅http://go.microsoft.com/fwlink/?LinkId=65455上的MSDN文档.WS-Metadata Exchange错误URI:net.tcp:// localhost:12345 / DataProvider / mex元数据包含无法解析的引用:'net.tcp:// localhost:12345 / DataProvider / mex'。 There is an error in the XML document. XML文档中存在错误。 The value for the 'type' attribute is invalid - 'q2:PersonFilter' is an invalid value for the 'type' attribute. 'type'属性的值无效 - 'q2:PersonFilter'是'type'属性的无效值。

The strange behaviour starting here: when do nothing, but remove just one of service operations, everything goes very well - adding of the Service Reference works super good. 从这里开始的奇怪行为:什么都不做,但删除一个服务操作,一切都很顺利 - 添加服务参考工作超级好。 Of course, I did not tried to remove every method of those ~40, but I've tried ~5. 当然,我没有尝试删除那些〜40的每一种方法,但我已经尝试过~5。 Another important thing - I did not remove the method which operates with the PersonFilter (the type shown in the error message). 另一个重要的事情 - 我没有删除使用PersonFilter操作的方法(错误消息中显示的类型)。

I have no idea, how to fix this. 我不知道,如何解决这个问题。 If more information is needed, just let me know. 如果需要更多信息,请告诉我。

UPDATE #1 更新#1

So, I've just tried to set mex custom binding to increase defult quotas: 所以,我只是尝试设置mex自定义绑定来增加defult配额:

  <customBinding>
    <binding name="mexBinding">
      <binaryMessageEncoding>
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" 
                      maxArrayLength="2147483647" maxBytesPerRead="2147483647" 
                      maxNameTableCharCount="2147483647" />
      </binaryMessageEncoding>
      <tcpTransport transferMode="Buffered" maxReceivedMessageSize="2147483647" 
                    maxBufferSize="2147483647" />
    </binding>
  </customBinding>

and

  <service name="MyNamespace.DataService" behaviorConfiguration="myServiceBehavior">
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost:12345/DataProvider/" />
      </baseAddresses>
    </host>

    <endpoint binding="netTcpBinding" bindingConfiguration="NetTcpBinding"
              contract="MyNamespace.IDataService" />
    <endpoint address="mex" binding="customBinding" bindingConfiguration="mexBinding"
              name="tcp" contract="IMetadataExchange" />
  </service>

but it does not help - the same error is still occuring. 但它没有帮助 - 同样的错误仍然存​​在。

UPDATE #2 更新#2

Using ServiceModel Metadata Utility Tool (Svcutil.exe) I've tried to get metadata from 3 following sources: 使用ServiceModel元数据实用工具(Svcutil.exe)我试图从以下3个来源获取元数据:

  1. HTTP host HTTP主机
  2. TCP host TCP主机
  3. Assembly directly 直接汇编

As for sources 1. and 3. - everything goes fine. 至于来源1.和3. - 一切都很顺利。 I'm able to get metadata and generate client code, but when I call svcutil over TCP host I'm getting: 我能够获取元数据并生成客户端代码,但是当我通过TCP主机调用svcutil ,我得到:

Microsoft (R) Service Model Metadata Tool [Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.1] Copyright (c) Microsoft Corporation. Microsoft(R)服务模型元数据工具[Microsoft(R)Windows(R)Communication Foundation,版本4.0.30319.1]版权所有(c)Microsoft Corporation。 All rights reserved. 版权所有。

Attempting to download metadata from 'net.tcp://localhost:12345/DataProvider/mex' using WS-Metadata Exchange. 尝试使用WS-Metadata Exchange从'net.tcp:// localhost:12345 / DataProvider / mex'下载元数据。 This URL does not support DISCO. 此URL不支持DISCO。

Microsoft (R) Service Model Metadata Tool [Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.1] Copyright (c) Microsoft Corporation. Microsoft(R)服务模型元数据工具[Microsoft(R)Windows(R)Communication Foundation,版本4.0.30319.1]版权所有(c)Microsoft Corporation。 All rights reserved. 版权所有。

Error: Cannot obtain Metadata from net.tcp://localhost:12345/DataProvider/mex 错误:无法从net.tcp:// localhost:12345 / DataProvider / mex获取元数据

If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. 如果这是您有权访问的Windows(R)Communication Foundation服务,请检查您是否已在指定地址启用元数据发布。 For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455 . 有关启用元数据发布的帮助,请参阅http://go.microsoft.com/fwlink/?LinkId=65455上的MSDN文档。

WS-Metadata Exchange Error URI: net.tcp://localhost:12345/DataProvider/mex WS-Metadata Exchange错误URI:net.tcp:// localhost:12345 / DataProvider / mex

 Metadata contains a reference that cannot be resolved: 'net.tcp://12345/DataProvider/Management/mex'. There is an error in the XML document. The value for the 'type' attribute is invalid - 'q2:PersonFilter' is an invalid value for the 'type' attribute. 

If you would like more help, type "svcutil /?" 如果您需要更多帮助,请输入“svcutil /?”

I'm still have no idea about what is wrong with my wcf service or its configuration. 我仍然不知道我的wcf服务或其配置有什么问题。

It is generally easier to get the service to work with basic http binding first and then change it to net tcp afterwards. 通常更容易使服务首先使用基本的http绑定,然后将其更改为net tcp。

In addition to defining a mex endpoint you need to enable metadata exchange: 除了定义mex端点,您还需要启用元数据交换:

<behaviors> 
  <serviceBehaviors> 
    <behavior name="myServiceBehavior"> 
        <serviceDebug includeExceptionDetailInFaults="True" /> 
        <serviceMetadata /> 
    </behavior> 
   </serviceBehaviors> 
 </behaviors> 

Without the <serviceMetadata /> element the mex endpoints will not work. 如果没有<serviceMetadata />元素,mex端点将无法工作。

Well, I found the solution a long time ago, but I'm completely forgot to post an answer. 好吧,我很久以前就找到了解决方案,但我完全忘了发布答案。

So, I have made some changes in the Visual Studio config file devenv.exe.config . 所以,我在Visual Studio配置文件devenv.exe.config做了一些更改。 I've just added the system.serviceModel section as follows: 我刚刚添加了system.serviceModel部分,如下所示:

<system.serviceModel>
    <client>
        <endpoint binding="netTcpBinding" bindingConfiguration="GenericBinding" contract="IMetadataExchange" name="net.tcp" />
    </client>
    <bindings>
        <netTcpBinding>
            <binding name="GenericBinding"
                     maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
                     maxReceivedMessageSize="2147483647">
                <readerQuotas maxDepth="2147483647"
                              maxStringContentLength="2147483647"
                              maxArrayLength="2147483647"
                              maxBytesPerRead="2147483647"
                              maxNameTableCharCount="2147483647" />
                <security mode="None" />
            </binding>
        </netTcpBinding>
    </bindings>
</system.serviceModel>

Now everything works without any problem. 现在一切正常,没有任何问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM