首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SoapHeader类和DataContractAttribute

SoapHeader类和DataContractAttribute
EN

Stack Overflow用户
提问于 2011-12-16 00:17:28
回答 2查看 824关注 0票数 1

我有一个错误:

代码语言:javascript
复制
Type 'MyAppApp.Web.MyAppWebService.NotifierAuthHeader' cannot inherit from a type that is not marked with DataContractAttribute or SerializableAttribute. Consider marking the base type 'System.Web.Services.Protocols.SoapHeader' with DataContractAttribute or SerializableAttribute, or removing them from the derived type.

在执行此wcf方法时:

代码语言:javascript
复制
<OperationContract()> <WebMethod(Description:="Gets details about selected PDF document")> _
    Public Function GetPdfDetails(ByVal pdfName As String) As String

我无法更改SoapHeader,因为它是框架类

代码语言:javascript
复制
Public MustInherit Class SoapHeader
          Inherits System.Object
     Member of System.Web.Services.Protocols

我在NotifierAuthHeader类中使用了这个类

代码语言:javascript
复制
Imports System.Web.Services.Protocols
Imports System.Runtime.Serialization 

Public Class NotifierAuthHeader
    Inherits SoapHeader

    Public HandlerId As Integer
    Public Guid As Byte()
End Class

我有点困惑。我怎么才能让它工作呢?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-12-16 00:53:31

您是否有意将两种技术混合在一起?SoapHeader来自遗留的ASMX技术,而OperationContract来自WCF。

要在WCF中使用标头,您需要使用消息约定,它可以包含标头部分和正文部分。

票数 1
EN

Stack Overflow用户

发布于 2011-12-16 00:37:12

我认为您需要将WebMethod与OperationContract分开。

如果目标是对Web服务和WCF服务使用相同的方法,则需要将该方法的副本移动到单独的asmx中。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8523180

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档