急急急····wcf没有终结点对可能接受消息的 进行监听
我winform中写了一个wcf服务 代理类是用NetCFSvcUtil.exe生成的 然后再另一个类中替换连接地址
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; }
<add key="WebServiceUrl" value="开发服务器" /> <add key="_开发服务器" value="localhost:18088/RFServiceHost"/>
_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);
<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>
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();