我正在使用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>
我输入&#34; net.tcp:// [server:port] / [iis上的网站] /Shared/Shared.svc"进入地址框并单击GO并获取错误。
我做错了什么?
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.
答案 0 :(得分:0)
正如CodeCaster在评论中所述,您应启用元数据发布(<serviceMetadata httpGetEnabled="true" />
)并添加 mexHttpBinding 类型的 mex 端点(因此请使用 http://[server:port]/[website on iis] /UITax/Reports.svc )添加服务引用。 OR 添加 mexTcpBinding 类型的 mex 端点并使用您的net.tcp地址添加服务参考
元数据交换的端点:
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
或者
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>