【问题标题】:create net.tcp service reference in client app using VS2015使用 VS2015 在客户端应用程序中创建 net.tcp 服务引用
【发布时间】:2015-10-21 21:26:26
【问题描述】:

我正在使用 VS2015 并为 Web 服务创建 WPF 客户端应用程序。该服务在我的网络上的专用 Web 服务器上的 IIS 上运行。当我尝试添加服务引用时,我收到一条错误消息,指出它无法识别 uri 前缀。

web服务web.config文件如下:

<system.serviceModel>
<diagnostics wmiProviderEnabled="true">
  <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<bindings>
  <netTcpBinding>
    <binding name="netTcpBinding-Streamed" transferMode="Streamed" maxReceivedMessageSize="1073741824">
      <readerQuotas maxStringContentLength="8192000" />
    </binding>
  </netTcpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <serviceAuthorization principalPermissionMode="UseWindowsGroups" />
      <serviceMetadata httpGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
<service name="[Namespace].Services.IIS">
    <endpoint address="net.tcp://[server:port]/[website on iis]/Shared/Shared.svc" bindingConfiguration="netTcpBinding-Streamed" binding="netTcpBinding" contract="[Namespace].Services.Interfaces.Shared.IShared" />
        <endpoint address="net.tcp://[server:port]/[website on iis]/UITax/Reports.svc" bindingConfiguration="netTcpBinding-Streamed" binding="netTcpBinding" contract="[Namespace].Services.Interfaces.UITax.Reports.IReport" />
        <endpoint address="net.tcp://[server:port]/[website on iis]/UITax/Assignments.svc" bindingConfiguration="netTcpBinding-Streamed" binding="netTcpBinding" contract="[Namespace].Services.Interfaces.UITax.Assignments.IAssignments" />
    </service>
</services>
<extensions>
  <behaviorExtensions>
    <add name="errorHandler" type="[Namespace].Services.Framework.WCF.WcfErrorHandlerExtension, [Namespace].Services.WCF.Framework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
  </behaviorExtensions>
</extensions>

我在“地址”框中输入“net.tcp://[server:port]/[website on iis]/Shared/Shared.svc”,然后单击“开始”并出现错误。

我做错了什么?

VS2015 错误信息:

The URI prefix is not recognized.
Metadata contains a reference that cannot be resolved: 'net.tcp://[server:port]/[website on iis]/shared/shared.svc'.
The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:04:59.9980001'.
An existing connection was forcibly closed by the remote host
If the service is defined in the current solution, try building the solution and adding the service reference again.

【问题讨论】:

  • 如果要生成服务引用,元数据必须根据thisthis问题通过HTTP。
  • 请在您的帖子中包含错误信息。
  • CodeCaster:关于您的第一个参考链接 - 其他应用程序正在使用 Web 服务,但我无权访问源代码。所以我假设 web.config 文件不是问题。
  • CodeCaster:至于您的第二个参考链接,服务项目不是我的解决方案或项目的一部分。另外设置“httpGetEnabled=true”会破坏所有使用该服务的现有应用程序。

标签: c# wpf wcf


【解决方案1】:

正如 CodeCaster 在对问题的评论中所说,您应该启用元数据发布 (&lt;serviceMetadata httpGetEnabled="true" /&gt;) 并添加类型为 mexHttpBindingmex 端点(所以使用 @ 987654321@ on iis]/UItax/Reports.svc) 添加服务参考。 添加 mex 类型为 mexTcpBinding 的端点并使用您的 net.tcp 地址添加服务引用

元数据交换端点:

<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>

或者

<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>

【讨论】:

  • 我不确定您的建议。我是否需要更改服务器 Web 配置中的端点
  • 我不确定您的建议。我是否需要将服务器的 web.config 文件中的端点地址更改为“mex”?此外,正如我在上面回复 CodeCaster 时提到的,当我将 httpGetEnabled 从“false”更改为“true”时,会破坏使用此服务的所有其他应用程序。
  • 不改名字,多加一个端点。只需在已经存在的端点之后添加此行
  • 请在此处查看非常详细的描述msdn.microsoft.com/en-us/library/ms734765.aspx
  • 我在 web.config 文件中添加了另一个端点: 并将 httpGetEnabled 更改为 true。我仍然收到相同的错误消息。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-09-11
  • 2012-12-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-04
  • 1970-01-01
相关资源
最近更新 更多