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

lxig20077 2012-09-17 03:38:00
我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;
}


webconfig 中配置


<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);


在服务端webconfig中配置

<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进行监听

各位帮帮忙!



...全文
256 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lxig20077 2012-09-19
  • 打赏
  • 举报
回复
ServiceHost 就是一个svc文件
  • 打赏
  • 举报
回复
在你的winform中,根本无需有什么web.config文件,有了也毫无作用。

一个wcf服务器注册很简单,例如:
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();


这里就把一个类型service按照路径地址host进行注册,然后你就可以从浏览器上直接访问它的wsdl。

无需写上那一大堆什么web.config内容。半行内容也不需要。
  • 打赏
  • 举报
回复
晕死!

地址改变应该仅仅在客户端去动态提供参数,你怎么写在服务器端?起什么作用?
机器人 2012-09-19
  • 打赏
  • 举报
回复
直接在浏览器里输入:

http://localhost:18088/RFServiceHost/MB.ERP.RFLibrary.MRF.IFace/RFLogin.svc?wsdl 有效不?
机器人 2012-09-17
  • 打赏
  • 举报
回复
ServiceHost 的代码呢?
lxig20077 2012-09-17
  • 打赏
  • 举报
回复
有没有人啊

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧