接上一篇博客,继续进行测试和调试
将项目重新生成解决方案后,不再报错误,之后尝试运行UI,看程序是否能正常运行,但是在运行过程中报错了,图示下:
上面这个IP地址是写在本地服务端UI层的,所以需要先确定服务端是否也存在问题,然后做了下面的操作。
想要在IIS发布之前,现在浏览器中浏览一遍,看一看服务器是否能正常运行,在svc文件右键,点击在浏览器中浏览,结果:
出现了错误,会很头疼,但是越焦虑越找不到方法,所以还是理智下来,好好找解决方法吧!
理一理思路,可能是配置文件错误,也可能是WCF创建的 .svc文件错误。之后开始排查应用程序配置文件
app.config 的基本格式:
<configuration>
<startup>
<supportedRuntime version ="v4.0" sku =".NETFramework,Version=v4.0"/>
</startup>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
<!--解决服务器端不能发布成功--><!--
<serviceActivations >
<add relativeAddress="Service1.svc" service="WcfService.Service"/>
</serviceActivations>-->
</serviceHostingEnvironment>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_Default" closeTimeout="00:05:00" openTimeout="00:05:00" receiveTimeout="00:20:00" sendTimeout="00:05:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="false" messageEncoding ="Text">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType ="None" realm=""></transport>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<!--终结点ABC-->
<client>
<!--<endpoint address="http://localhost:7221/Service.svc?wsdl" binding ="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Default" contract="*" name="BasicHttpBinding_Services"></endpoint>-->
<endpoint address=" http://localhost:10582/Service1.svc?wsdl" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Default" contract="Contracts.IService" name="BasicHttpBinding_Services"></endpoint>
<!--<endpoint address="http://localhost:7221/Service.svc?wsdl" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_Default" contract="ITOO.Library.Test.Service.Contracts.IService" name="BasicHttpBinding_Services"/>-->
</client>
</system.serviceModel>
</configuration>
方法1:将终结点endpoint的地址:http://localhost:7221/Service.svc?wsdl 修改为服务器端的地址http://192.168.26.*7221/Service.svc?wsdl
方法2:将svc文件中的内容进行修改如图:
wcf层目录
wcf 中svc文件代码
<%@ ServiceHost Language="C#" Debug="true" Service="WCFService.Service1" CodeBehind="Service.svc.cs" %>将Service的属性修改为服务名称;
<%@ ServiceHost Language="C#" Debug="true" Service="ITOO.Library.Test.Service.WCFService.Service" CodeBehind="Service.svc.cs" %>
博客比较水,但是代表了这一天的收获,调试错误永远都会有一个解决方案在等着你,或许是众里寻她,或许是蓦然回首,总之,相信,一定有一个方法在等着你。
无法激活请求的服务“http://localhost:10582/Service1.svc?wsdl”
原文:http://blog.csdn.net/mayfla/article/details/46390239