我能够在我自己的服务器中调用它,它可以工作,但是当我在IIS中托管wcf服务时会出现问题。此错误的详细信息如下...WCF调用服务失败
无法调用该服务。可能的原因:该服务离线 或无法访问;客户端配置与 代理不匹配;现有的代理无效。有关更多详细信息,请参阅 的堆栈跟踪。您可以尝试通过启动新代理,将 恢复为默认配置或刷新服务来进行恢复。
堆栈跟踪错误详细信息
服务器由于内部错误无法处理该请求。 有关错误的 IncludeExceptionDetailInFaults(无论是从ServiceBehaviorAttribute 或从
<serviceDebug>
配置行为)的服务器的详细信息,或者反过来在 为了将异常信息发送回客户端,或打开 跟踪按照微软.NET Framework 3.0 SDK文档和 检查服务器跟踪日志。服务器堆栈跟踪:
在System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(消息 回复,MessageFault故障,字符串动作,MessageVersion版本, FaultConverter faultConverter)
在System.ServiceModel.Channels.ServiceChannel.HandleReply (ProxyOperationRuntime 操作,ProxyRpc & RPC)
在System.ServiceModel.Channels.ServiceChannel.Call(字符串动作, 布尔单向,ProxyOperationRuntime操作,对象[]插件, 对象[]奏,时间跨度超时)
在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage 包括MethodCall,ProxyOperationRuntime操作)
在System.ServiceModel.Channels.ServiceChannelProxy.Invoke(即时聊天 消息)[0]时异常重新抛出:
在System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(即时聊天 reqMsg,即时聊天retMsg)
在System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData & MSGDATA,的Int32类型)
在IUserService.GetUser(S特林用户ID)
在UserServiceClient.GetUser(字符串userid)
下面是源代码:
应用程序。从wcfservicelirbrary
<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.web> <compilation debug="true" /> </system.web> <system.serviceModel> <services> <service name="UserServiceLibrary.UserService"> <endpoint address="" binding="wsHttpBinding" contract="UserServiceLibrary.IUserService"> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="http://localhost:8732/Design_Time_Addresses/UserServiceLibrary/UserService/" /> </baseAddresses> </host> </service> </services> <behaviors> <serviceBehaviors> <behavior> <serviceMetadata httpGetEnabled="True"/> <serviceDebug includeExceptionDetailInFaults="False" /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> </configuration>
的Web配置文件配置文件从WCF网站主机
<?xml version="1.0"?> <configuration> <system.web> <compilation debug="false" targetFramework="4.0" /> </system.web> <system.serviceModel> <services> <service name="UserServiceLibrary.UserService"> <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange" /> <endpoint address="basic" binding="basicHttpBinding" bindingConfiguration="" contract="UserServiceLibrary.IUserService" /> <endpoint address="" binding="wsHttpBinding" contract="UserServiceLibrary.IUserService" /> </service> </services> <behaviors> <serviceBehaviors> <behavior> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> </configuration>
首先,转到服务器并应用以下配置更新: http://msdn.microsoft.com/en-us/library/system.servicemodel.servicebehaviorattribute .includeexceptiondetailinfaults.aspx – dotnetnate
另请看'UserServi ceClient.GetUser(String UserID)' - 这是最初发生异常的地方。发布你的代码和你从dotnetnate的建议获得的更多信息,以获得更好的答案:) – Tim
好的,我会先尝试.... –