这个 WCF 错误是什么意思:“自定义工具警告:无法导入 wsdl:portType"? [英] What does this WCF error mean: "Custom tool warning: Cannot import wsdl:portType"

查看:42
本文介绍了这个 WCF 错误是什么意思:“自定义工具警告:无法导入 wsdl:portType"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的解决方案中创建了一个 WCF 服务库项目,并且有对此的服务引用.我使用类库中的服务,因此除了类库之外,我还有来自 WPF 应用程序项目的引用.服务是直接设置的——只是为了获得异步服务功能而改变.

I created a WCF service library project in my solution, and have service references to this. I use the services from a class library, so I have references from my WPF application project in addition to the class library. Services are set up straight forward - only changed to get async service functions.

一切正常 - 直到我想更新我的服务引用.它失败了,所以我最终回滚并重试,但即使那样也失败了!所以 - 更新服务引用失败,而不对其进行任何更改.为什么?!

Everything was working fine - until I wanted to update my service references. It failed, so I eventually rolled back and retried, but it failed even then! So - updating the service references fails without doing any changes to it. Why?!

我得到的错误是:

Custom tool error: Failed to generate code for the service reference 
'MyServiceReference'.  Please check other error and warning messages for details.   

警告提供了更多信息:

Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: 
System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: List of referenced types contains more than one type with data contract name 'Patient' in  
namespace 'http://schemas.datacontract.org/2004/07/MyApp.Model'. Need to exclude all but one of the 
following types. Only matching types can be valid references: 
"MyApp.Dashboard.MyServiceReference.Patient, Medski.Dashboard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" (matching)
"MyApp.Model.Patient, MyApp.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" (matching)
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='ISomeService']

还有两个类似的警告说:

There are two similar warnings too saying:

Custom tool warning: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='ISomeService']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:binding[@name='WSHttpBinding_ISomeService']  

同样适用于:

Custom tool warning: Cannot import wsdl:port .. 

我觉得这一切都令人困惑..除了我通过服务参考获得的那个之外,我在客户端仪表板上没有一个 Patient 类.那么它是什么意思呢?为什么会突然显示?记住:我什至没有改变任何东西!

I find this all confusing.. I don't have a Patient class on the client side Dashboard except the one I got through the service reference. So what does it mean? And why does it suddenly show? Remember: I didn't even change anything!

现在,在这里找到了解决方案,但没有解释这意味着什么.所以;在服务的配置服务引用"中,我取消选中在引用的程序集中重用类型"复选框.现在重建一切正常,没有问题.但我真正改变了什么?这会影响我的申请吗?什么时候应该取消选中这个?我确实想重用我在其上设置 DataContract 的类型,但仅此而已.我是否仍然可以访问那些没有经过检查的人?

Now, the solution to this was found here, but without an explanation to what this means. So; in the "Configure service reference" for the service I uncheck the "Reuse types in the referenced assemblies" checkbox. Rebuilding now it all works fine without problems. But what did I really change? Will this make an impact on my application? And when should one uncheck this? I do want to reuse the types I've set up DataContract on, but no more. Will I still get access to those without this checked?

推荐答案

添加服务引用时,可以通过两种方式处理服务使用的类型:

When you add a service reference, there are two ways the types that are used by the service can be handled:

  • 类型存储在一个 dll 中,该 dll 被客户端和服务器应用程序引用.
  • 类型不在客户端引用的 dll 中.在这种情况下,创建服务引用的工具将在references.cs 文件中创建类型.

有很多事情可能会出错.我们发现,如果工具崩溃,有时删除服务引用并重新启动会更快.

There are many things that can go wrong. We have found that if the tool crashes, it is sometimes faster to delete the service reference and start again.

我们已停止使用服务引用.对于我们可以控制客户端和服务的项目,我们使用中描述的方法截屏.

We have stopped using service reference. For projects where we have control of the client and the service, we use the method described in this screencast.

这篇关于这个 WCF 错误是什么意思:“自定义工具警告:无法导入 wsdl:portType"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆