首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web Service >

急····wcf没终结点对可能接受消息的 进行监听

2012-11-06 
急急急wcf没有终结点对可能接受消息的 进行监听我winform中写了一个wcf服务 代理类是用NetCFSvcUtil.exe生

急急急····wcf没有终结点对可能接受消息的 进行监听
我winform中写了一个wcf服务 代理类是用NetCFSvcUtil.exe生成的 然后再另一个类中替换连接地址

C# code
 public static RFLoginClient connectLoginService(string serviceAdress)        {            RFLoginClient _serviceClient;            //if (_serviceClient == null)            //{            BasicHttpBinding httpBinding = new BasicHttpBinding();            httpBinding.MaxReceivedMessageSize = 2147483647;            httpBinding.SendTimeout = new TimeSpan(0, 10, 0);            //System.ServiceModel.Channels.Binding binding = SfTaskPknClient.CreateDefaultBinding();            string remoteAddress = RFLoginClient.EndpointAddress.Uri.ToString();            remoteAddress = remoteAddress.Replace("localhost", serviceAdress);            EndpointAddress endpoint = new EndpointAddress(remoteAddress);            _serviceClient = new RFLoginClient(httpBinding, endpoint);            // }            return _serviceClient;        }

webconfig 中配置 
C# code
<add key="WebServiceUrl" value="开发服务器"  />    <add key="_开发服务器" value="localhost:18088/RFServiceHost"/>


在客户端调用是这样写的
C# code
  _loginParams = new LoginParams();                _loginParams.ServiceAdress = _settings.GetString("_" + cmbServer.Text);                //LoginParams._ServiceAdress = _loginParams.ServiceAdress;                _serviceClient = ServiceUtil.connectLoginService(_loginParams.ServiceAdress);                //_serviceClient 中的地址在调试中看到 地址跟浏览器地址是一样的                 // 登录验证                LoginInfo loginInfo = _serviceClient.Login(this.cmbUserCode.Text, this.txtPSW.Text, this.cmbWarehouse.Text);


在服务端webconfig中配置
C# code
 <system.serviceModel>    <protocolMapping>      <add scheme="http" binding="basicHttpBinding" bindingConfiguration="MyBasicHttpBinding" />    </protocolMapping>    <bindings>      <basicHttpBinding>        <binding name="MyBasicHttpBinding" closeTimeout="01:10:00" openTimeout="01:01:00" receiveTimeout="01:10:00" sendTimeout="01:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">          <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />          <security mode="None">            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />            <message clientCredentialType="UserName" algorithmSuite="Default" />          </security>        </binding>      </basicHttpBinding>    </bindings>    <behaviors>      <serviceBehaviors>        <behavior>          <serviceDiscovery />          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->          <serviceMetadata httpGetEnabled="true" />          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->          <serviceDebug includeExceptionDetailInFaults="true" />          <dataContractSerializer maxItemsInObjectGraph="2147483646" />          <serviceThrottling maxConcurrentCalls="10000" maxConcurrentInstances="10000" maxConcurrentSessions="20000" />        </behavior>      </serviceBehaviors>    </behaviors>    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />  </system.serviceModel> 



服务在浏览器中能浏览 但是报错:
wcf没有终结点对可能接受消息的http://localhost:18088/RFServiceHost/MB.ERP.RFLibrary.MRF.IFace/RFLogin.svc进行监听

各位帮帮忙!





[解决办法]
直接在浏览器里输入:

http://localhost:18088/RFServiceHost/MB.ERP.RFLibrary.MRF.IFace/RFLogin.svc?wsdl 有效不?
[解决办法]
在你的winform中,根本无需有什么web.config文件,有了也毫无作用。

一个wcf服务器注册很简单,例如:
C# code
var station = new ServiceHost(serviceType, host);var behaviour = new ServiceMetadataBehavior();behaviour.HttpGetEnabled = true;behaviour.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;station.Description.Behaviors.Add(behaviour);station.AddServiceEndpoint(serviceType, new BasicHttpBinding(), host);station.Open(); 

热点排行