简体   繁体   English

从WCF服务调用类库时出错

[英]Error calling a class library from a wcf service

I have an MVC project where I am using a WCF service as a pass through to methods in a class library. 我有一个MVC项目,在这里我使用WCF服务作为类库中方法的传递。 I put a query in the service and called the service from my project and the query worked fine and returned the result. 我在服务中放置了一个查询,并从我的项目中调用了该服务,该查询运行良好并返回了结果。 I have changed my code to point directly at the class library and the method runs great and returns what I expect. 我将代码更改为直接指向类库,该方法运行良好并返回了我期望的结果。 When I call the web service which just has a call to the class library and returns the result, it breaks. 当我调用仅对类库有调用并返回结果的Web服务时,它就会中断。 The error I get in the code is: 我在代码中得到的错误是:

An error occurred while receiving the HTTP response to 'url'. 收到对“ url”的HTTP响应时发生错误。 This could be due to the service endpoint binding not using the HTTP protocol. 这可能是由于服务端点绑定未使用HTTP协议。 This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). 这也可能是由于服务器终止了HTTP请求上下文(可能是由于服务关闭了)。 See server logs for more details. 有关更多详细信息,请参见服务器日志。

While researching this I found several people said this is a generic 'It broke' error and to enable tracing. 在研究此问题时,我发现有几个人说这是一个通用的“ It Break”错误并启用了跟踪。 When I turn on tracing I only see one error message: 当我打开跟踪时,我只会看到一条错误消息:

Content Type application/soap+xml; 内容类型application / soap + xml; charset=utf-8 was sent to a service expecting text/xml; charset = utf-8已发送到需要text / xml的服务; charset=utf-8. charset = utf-8。 The client and service bindings may be mismatched. 客户端和服务绑定可能不匹配。

I don't define any bindings in my .config files. 我没有在.config文件中定义任何绑定。 I had this set up working but changes were made to the class library to make it more object oriented. 我已经进行了此设置,但是对类库进行了更改以使其更加面向对象。 I have resolved all of the errors stemming from that change but I can't figure this error out. 我已经解决了由该更改引起的所有错误,但是我无法弄清楚该错误。 I have tried several of the fixes I found by googling this error but none of them have been successful. 我已经尝试通过谷歌搜索此错误找到了一些修复程序,但是都没有成功。 Does anyone have any suggestions on what else I can try? 有人对我可以尝试的方法有任何建议吗?

Edit: 编辑:

Looking at the config of my project a binding was setup when I set the web service reference. 查看我项目的配置,当我设置Web服务引用时就设置了绑定。 It is using basichttp binding. 它正在使用basichttp绑定。 I am guessing now that I can talk to the part separately since the first binding is defined and the second is auto detect. 我现在猜想是因为第一个绑定已定义,第二个是自动检测,所以我可以分别与该部分交谈。 I am thinking my issue is when the 2 auto detect parts talk to each other. 我想我的问题是2个自动检测部件互相通话时。 Trying to figure something along that angle. 试图从那个角度看一些东西。

My manager was the one that changed my class library. 我的经理是改变我班级图书馆的人。 She changed all of the id's that I had on my objects to objects. 她将我在对象上拥有的所有ID更改为对象。 So a reservation instead of having a event id had an event object. 因此,保留而不是事件ID保留了一个事件对象。 In doing this she created a series of loops where an event has a room object which has an event object. 为此,她创建了一系列循环,其中一个事件具有一个房间对象,而该房间对象具有一个事件对象。 Or a person has an address object which has a person object. 或者一个人的地址对象中有一个人对象。 So the errors I was getting above really were generic "it broke" messages. 因此,我遇到的错误实际上是通用的“ it break”消息。

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

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