简体   繁体   English

使用使用 SvcUtil.exe 创建的服务引用托管 .NET 服务时出现问题:Wrapped 模式下的 XmlSerializer 错误

[英]Problems hosting a .NET service using a service reference created using SvcUtil.exe: XmlSerializer errors on Wrapped mode

My problem is the following:我的问题如下:

  • Here http://www.opcfoundation.org/webservices/XMLDA/1.0/ I use VS2010 in order to create a service reference.这里http://www.opcfoundation.org/webservices/XMLDA/1.0/我使用 VS2010 来创建服务引用。 I create it with no problems.我创建它没有问题。

  • I want to implement the service interface creating a service of mine.我想实现创建我的服务的服务接口。 So I implement the Service interface.所以我实现了Service接口。

  • I create a svc file:我创建一个 svc 文件:

     <%@ ServiceHost Language="C#" Debug="true" Service="Full name of the class (the class implementing the Service interface)" %>

OK, I got this:好的,我明白了:

XmlSerializer attribute System.Xml.Serialization.XmlAttributeAttribute is not valid in LocaleID. XmlSerializer 属性 System.Xml.Serialization.XmlAttributeAttribute 在 LocaleID 中无效。
Only XmlElement, XmlArray, XmlArrayItem, XmlAnyAttribute and XmlAnyElement attributes仅 XmlElement、XmlArray、XmlArrayItem、XmlAnyAttribute 和 XmlAnyElement 属性
are supported when IsWrapped is true.当 IsWrapped 为真时支持。

Let me point the following:让我指出以下几点:
Do not ask me for Web.config file, whether it has a service model configuration settings or not, it is not different, the same problem persists.不要问我Web.config文件,有没有服务model配置设置,没有区别,同样的问题依旧。

What's the problem?有什么问题?

I've been wondering around to solve this, I would like to note that, in the past, someone else used wsdl.exe in order to create an asp.net service reference that uses WebService and WebMethod as service attributes, that approach does not lead to this error.我一直在想解决这个问题,我想指出,过去,其他人使用 wsdl.exe 来创建使用WebServiceWebMethod作为服务属性的 asp.net 服务引用,这种方法不会导致这个错误。
But I would like to use WCF...但我想用 WCF...

This link shall help you, it has direct explanation of the problem and possible way-outs. 此链接将对您有所帮助,它对问题和可能的出路有直接的解释。

I had the same issue with the OPC DA specification.我对 OPC DA 规范有同样的问题。 I switched to the old-style .NET Webservices (web reference instead of service reference).我切换到旧式 .NET Webservices(Web 参考而不是服务参考)。 The .NET webservices do accept the WSDL specification of the OPC foundation. .NET Web 服务确实接受 OPC 基金会的 WSDL 规范。

These are the steps I took to create such a proxy:这些是我创建这样一个代理所采取的步骤:

  1. Create a .NET v2 project.创建 .NET v2项目。
  2. Add a Web reference to http://www.opcfoundation.org/webservices/XMLDA/1.0将 Web 引用添加到http://www.opcfoundation.org/webservices/XMLDA/1.0
  3. Adjust the project settings, so it compiles for .NET v4 again.调整项目设置,使其再次编译为 .NET v4。
  4. Use the proxies.使用代理。

It's not an ideal solution, but it's beats creating your own wrapper.这不是一个理想的解决方案,但它比创建自己的包装器要好。

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

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