【问题标题】:trying to consume wcf service but I think my web.config file is incorrect尝试使用 wcf 服务,但我认为我的 web.config 文件不正确
【发布时间】:2011-05-09 18:55:42
【问题描述】:

我正在尝试使用服务。我正在尝试将其部署到服务器并使用它,但是出现此错误。我创建了一个 Web 应用程序并添加了一个 wcf 服务。我得到了这个

服务器堆栈跟踪: 在 System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest 请求,HttpWebResponse 响应,HttpChannelFactory 工厂,WebException responseException,ChannelBinding 通道绑定) 在 System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(时间跨度超时) 在 System.ServiceModel.Channels.RequestChannel.Request(消息消息,TimeSpan 超时) 在 System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息消息,TimeSpan 超时) 在 System.ServiceModel.Channels.ServiceChannel.Call(字符串操作,布尔单向,ProxyOperationRuntime 操作,Object[] 输入,Object[] 输出,TimeSpan 超时) 在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage 方法调用,ProxyOperationRuntime 操作) 在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 消息)

在 [0] 处重新抛出异常: 在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg) 在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,Int32 类型) 在 IBusinessV1.CheckForUpdate(字符串 currentVersion) 在 BusinessV1Client.CheckForUpdate(String currentVersion)

我的配置有问题吗?

<system.serviceModel>
   <services>
      <service name="SP.WebWCF.Business_v1">
          <endpoint 
             address="https://services.mydomain.com" 
             binding="basicHttpBinding"
             bindingConfiguration="" 
             contract="SP.WebWCF.IBusiness_v1"
             listenUri="/" isSystemEndpoint="true" />
      </service>
    </services>
    <behaviors>
       <serviceBehaviors>
           <behavior>
              <serviceMetadata httpGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="false"/>
           </behavior>
       </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>

【问题讨论】:

  • 此服务托管在哪里:IIS 还是自托管?

标签: c# wcf wcf-client


【解决方案1】:

好的,所以你确实显示了服务器配置,但你从未真正告诉我们错误是什么——你显示了堆栈跟踪——但没有显示错误消息.....

不管怎样,看看你的服务配置,有一件事似乎有点奇怪——你的服务地址:

address="https://services.mydomain.com" 
binding="basicHttpBinding"

通常这会是类似

address="https://services.mydomain.com/MyServiceVirtualDir/MyService.svc" 

如果您在 IIS 中托管您的服务,或者类似的东西

address="https://services.mydomain.com/MyService" 

如果您在 Windows NT 服务或其他东西中自托管。

您能否再次检查您的地址 - 您 100% 确定它是正确的吗??

更新:另外,您使用的是 https://,但是,您的服务配置中没有显示任何安全设置。仅供测试:当您将配置中的服务地址更改为 http:// 时,您可以调用您的服务吗??

【讨论】:

  • 对不起,这是我的服务。我正在尝试使用 WCF 测试客户端使用该服务,但出现上述错误
  • @user293545:不幸的是,你从来没有给我们错误——你得到的实际消息——只有堆栈跟踪......
  • 抱歉信息不足。我在站点根目录的 IIS 7 中托管该服务。那么服务端点应该看起来像“端点地址=“services.mydomain.com/Business_V1.svc”吗?因为这不起作用。我收到此错误无法调用服务。可能的原因:服务脱机或无法访问;客户端配置不匹配代理;现有代理无效。有关详细信息,请参阅堆栈跟踪。您可以尝试通过启动新代理、恢复到默认配置或刷新服务来恢复。
  • 是的,如果我将它添加到浏览器中,我的服务地址是正确的,我可以访问 wsdl
  • @user293545:是的,如果您在 IIS7 中托管,并且您使用的是 basicHttpBinding,您通常需要一个 *.svc 文件 - 除非您使用的是 . NET 4 和无文件激活 - 同样,您没有指定.....
猜你喜欢
  • 1970-01-01
  • 2011-08-11
  • 2016-07-12
  • 1970-01-01
  • 2023-01-23
  • 2023-03-21
  • 2022-01-05
  • 2018-11-16
  • 2012-12-04
相关资源
最近更新 更多