简体   繁体   English

发现的WCF服务无法连接

[英]Discovered WCF service can't connect

I have a WCF service that I'm using to expose a data source (connected to via an EF model). 我有一个WCF服务,我用它来公开数据源(通过EF模型连接)。 My endpoint for some reason just stopped responding. 我的端点由于某种原因刚刚停止响应。

Up until my last changes I was just pulling the data at startup of my app. 直到我上次的更改,我只是在启动应用程序时提取数据。 I'm now working on adding a subscribe/publish model on top of this so I can throw events when something hits the WCF service that results in the data changing (could do it in the client side but than I wouldn't catch other users changes). 我现在正在努力在此基础上添加订阅/发布模型,这样当我遇到导致数据发生变化的WCF服务时,我可以抛出事件(可以在客户端进行,但我不会抓住其他用户)变化)。

I've been following the example from Microsoft: http://msdn.microsoft.com/en-us/library/ms752254.aspx and added the appropriate decorations to my service interface and implementations and added a subscribe/unsubscribe OperationContract etc. I than try to fire up the service and can't connect. 我一直在关注微软的例子: http//msdn.microsoft.com/en-us/library/ms752254.aspx并将相应的装饰添加到我的服务接口和实现中,并添加了订阅/取消订阅OperationContract等。而不是尝试启动服务,无法连接。

I than dropped the Service Reference from my client and tried to reattach. 我从我的客户端删除了服务参考,并尝试重新附加。 Here is the strange thing: 这是奇怪的事情:

1) The WCF service builds and spins up in the developer host. 1)WCF服务在开发人员主机中构建和旋转。 2) The Web.Config file wasn't touched. 2)未触及Web.Config文件。 3) The "Discover Services" option in the add service reference in vs 2012 sees the service but when I try to actually accept the discovered service it throws an error saying "error downloading metadata from the address. 3)vs 2012中添加服务引用中的“发现服务”选项可以看到该服务,但是当我尝试实际接受发现的服务时,它会抛出一条错误,说“从地址下载元数据时出错”。

I don't get how it can discover the service and then not be able to add it as a reference. 我不知道它如何发现服务,然后无法将其添加为参考。 I can see if I added the info myself but it found it. 我可以看看我是否自己添加了信息,但它找到了它。

As part of adding the publishing functionality I added the SessionMode.Required tag to the interface I'm not really sure how WCF handles sessions and haven't ever had to deal with sessions anywhere else in my coding (generally pull the data from the source and than process it locally has been the types of tools I needed to make in the past so no state needed to be persisted server side). 作为添加发布功能的一部分,我将SessionMode.Required标记添加到接口我不确定WCF如何处理会话,并且从未在我的编码中的任何其他地方处理会话(通常从源中提取数据)并且比在本地处理它一直是我过去需要做的工具类型,所以没有状态需要持久化服务器端)。

Any ideas? 有任何想法吗?

my service web.config: 我的服务web.config:


 <connectionStrings> <add name="TaskModelContainer" connectionString="metadata=res://*/TaskModel.csdl|res://*/TaskModel.ssdl|res://*/TaskModel.msl;provider=System.Data.SqlClient;provider 

connection string="data source=winhacker\\sqlexpress;initial catalog=TaskDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient"/> connection string =“data source = winhacker \\ sqlexpress; initial catalog = TaskDB; integrated security = True; MultipleActiveResultSets = True; App = EntityFramework”“providerName =”System.Data.EntityClient“/>

Note: Note sure what is going on with the formating most of the file doesn't show up in the preview but sufficience it to say it is the boilerplate one that gets autogenerated other than I added a connectionStrings section to like to my EF datapoint. 注意:请注意确保格式化的大部分文件没有显示在预览中,但是它足以说它是一个自动生成的样板,而不是我添加了一个connectionStrings部分来喜欢我的EF数据点。 If you want to see the file click on "edit" seems to show the source I copied though a bit formatted weird. 如果你想看到文件点击“编辑”似乎显示我复制的源虽然有点格式化奇怪。

In the vast majority of cases where I have encountered this error, the issue has been a serialization issue on the server side; 在我遇到此错误的绝大多数情况下,问题一直是服务器端的序列化问题; WCF will throw an exception about this during the metadata discovery phase, but VS does not display this exception. WCF将在元数据发现阶段抛出异常,但VS不会显示此异常。

In order to troubleshoot this problem, you need to add a diagnostics section to your web.config to capture the WCF information into a svclog file, then use Microsoft's Service Trace Viewer to examine the log and discover the actual exception being thrown. 为了解决此问题,您需要在web.config添加一个诊断部分,以将WCF信息捕获到svclog文件中,然后使用Microsoft的服务跟踪查看器检查日志并发现引发的实际异常。

The web.config section should look something like this: web.config部分应如下所示:

  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel"
              switchValue="Information, ActivityTracing"
              propagateActivity="true">
        <listeners>
          <add name="traceListener"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData="c:\log\WebTrace.svclog"  />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>

and be added at the <configuration> level. 并在<configuration>级别添加。

Once you have added the configuration and ensure that the specified directory exists, try adding the service reference again. 添加配置并确保指定的目录存在后,请尝试再次添加服务引用。 This should cause the specified svclog file to be generated. 这应该导致生成指定的svclog文件。

If you have VS installed on that machine, you should be able to just double-click the file in Windows Explorer and have the log opened automatically in the tool. 如果在该计算机上安装了VS,则应该只需在Windows资源管理器中双击该文件,并在该工具中自动打开日志。

Once the log is opened, look down the list of activities in the left hand pane and click on the first one in red. 打开日志后,在左侧窗格中查看活动列表,然后单击第一个红色。 Then, in the top right pane, select the first one that is red (or shows an exception, I forget which). 然后,在右上方窗格中,选择第一个为红色(或显示异常,我忘记了哪个)。 You can then click on that to see the details, including exception information in the bottom right pane. 然后,您可以单击该按钮以查看详细信息,包括右下方窗格中的异常信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM