我在客服端添加服务引用时出现的问题,找不到我的配置文件如下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<client />
<bindings>
<netTcpBinding>
<binding name="netTcpConfig" portSharingEnabled="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="Windows" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="MyBehavior" name="WcfServiceLibrary.Service1">
<endpoint address="net.tcp://localhost:4305/WcfServiceLibrary/Service1"
binding="netTcpBinding" bindingConfiguration="netTcpConfig"
contract="WcfServiceLibrary.IService1" />
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8000" />
</baseAddresses>
<timeouts closeTimeout="00:01:00" />
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyBehavior">
<serviceMetadata httpGetEnabled="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>百度了好久也没找到问题,烦请高手帮忙看看,谢谢!我的大致步骤:
1.先新建一个WCF服务库
2.再host到添加的一个控制台程序
3.新建一个Windowns程序做客户端
在添加服务引用时找不到WCF服务请问这步骤是对的吗?不对应该是怎样?这里问题在哪?
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<client />
<bindings>
<netTcpBinding>
<binding name="netTcpConfig" portSharingEnabled="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="Windows" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="MyBehavior" name="WcfServiceLibrary.Service1">
<endpoint address="net.tcp://localhost:4305/WcfServiceLibrary/Service1"
binding="netTcpBinding" bindingConfiguration="netTcpConfig"
contract="WcfServiceLibrary.IService1" />
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8000" />
</baseAddresses>
<timeouts closeTimeout="00:01:00" />
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyBehavior">
<serviceMetadata httpGetEnabled="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>百度了好久也没找到问题,烦请高手帮忙看看,谢谢!我的大致步骤:
1.先新建一个WCF服务库
2.再host到添加的一个控制台程序
3.新建一个Windowns程序做客户端
在添加服务引用时找不到WCF服务请问这步骤是对的吗?不对应该是怎样?这里问题在哪?
解决方案 »
- 急急急 ,foreach,求助
- 通过WEBSERVICE返回一个对象
- 想用C#结合Window API做个任务栏图标右键菜单,怎么实现?
- CS文件中如何给在GridView中加上一列复选框?
- 怎么在PICTUREBOX 里面画图?
- [争鸣]只有9行代码编译不通过的原因?
- 帮我改改这段代码,js找不到变量,
- Windows服务简单问题
- 讨论(winform dataGrid)
- C#中从顶层窗口遍历所有子窗口,找特定类名的窗口,遇到一问题
- C#实现winform与本地sql数据库的连接、查询和返回功能。
- sql service把network service改为local service失败!再改回来就错误!而且服务业打不开了!求解决!
改为
<add baseAddress="http://localhost:8000" />
然后访问这个“http://localhost:8000”就可以得到引用了。
mex 的binding还要修改。直接用 net.tcp://localhost:4305/WcfServiceLibrary/Service1?wsdl 添加引用吧。
<serviceMetadata httpGetEnabled="true"/>
</behavior>
先试试
ServiceHost host = new ServiceHost(typeof(WcfService));
host.AddServiceEndpoint(typeof(IWcfService), new WSHttpBinding(), @"net.tcp://localhost:10000");
ServiceMetadataBehavior meta = new ServiceMetadataBehavior();
meta.HttpGetEnabled = true;
meta.HttpGetUrl = new Uri(@"http://localhost:10001");
host.Description.Behaviors.Add(meta);
host.Open();
if (host.State == CommunicationState.Opened)
{
Console.WriteLine("Host is opened");
}
Console.Read();
元数据包含无法解析的引用:“net.tcp://localhost:10000/”。
套接字连接已中止。这可能是由于处理消息时出错或远程主机超过接收超时或者潜在的网络资源问题导致的。本地套接字超时是“00:04:58.9959426”。
远程主机强迫关闭了一个现有的连接。
如果该服务已在当前解决方案中定义,请尝试生成该解决方案,然后再次添加服务引用。
下载“http://localhost:10001”时出错。
请求失败,错误信息为:
--
<HTML><HEAD><STYLE type="text/css">#content{ FONT-SIZE: 0.7em; PADDING-BOTTOM: 2em; MARGIN-LEFT: 30px}BODY{MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR: #000000; FONT-FAMILY: Verdana; BACKGROUND-COLOR: white}P{MARGIN-TOP: 0px; MARGIN-BOTTOM: 12px; COLOR: #000000; FONT-FAMILY: Verdana}PRE{BORDER-RIGHT: #f0f0e0 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #f0f0e0 1px solid; MARGIN-TOP: -5px; PADDING-LEFT: 5px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 5px; BORDER-LEFT: #f0f0e0 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: #f0f0e0 1px solid; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e5e5cc}.heading1{MARGIN-TOP: 0px; PADDING-LEFT: 15px; FONT-WEIGHT: normal; FONT-SIZE: 26px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 3px; MARGIN-LEFT: -30px; WIDTH: 100%; COLOR: #ffffff; PADDING-TOP: 10px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #003366}.intro{MARGIN-LEFT: -15px}</STYLE><TITLE>服务</TITLE></HEAD><BODY><DIV id="content"><P class="heading1">服务</P><BR/><P class="intro">由于内部错误,服务器无法处理该请求。有关该错误的详细信息,请打开服务器上的 IncludeExceptionDetailInFaults (从 ServiceBehaviorAttribute 或从 <serviceDebug> 配置行为)以便将异常信息发送回客户端,或在打开每个 Microsoft .NET Framework 3.0 SDK 文档的跟踪的同时检查服务器跟踪日志。</P></DIV></BODY></HTML>
--.
元数据包含无法解析的引用:“http://localhost:10001/”。
没有终结点在侦听可以接受消息的 http://localhost:10001/。这通常是由于不正确的地址或者 SOAP 操作导致的。如果存在此情况,请参阅 InnerException 以了解详细信息。
远程服务器返回错误: (404) 未找到。
如果该服务已在当前解决方案中定义,请尝试生成该解决方案,然后再次添加服务引用。
看你的代码, host 放在 using 里, ReadKey 放在 using 外。host 执行到 ReadKey 不就销毁了嘛...