2011-12-15 29 views
1

我有一個錯誤:SOAPHEADER類DataContractAttribute

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方法

<OperationContract()> <WebMethod(Description:="Gets details about selected PDF document")> _ 
    Public Function GetPdfDetails(ByVal pdfName As String) As String 

我無法改變SoapHeader因爲它的框架類

Public MustInherit Class SoapHeader 
      Inherits System.Object 
    Member of System.Web.Services.Protocols 

和我在NotifierAuthHeader類中使用這個類

Imports System.Web.Services.Protocols 
Imports System.Runtime.Serialization 

Public Class NotifierAuthHeader 
    Inherits SoapHeader 

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

我很困惑。我怎麼能工作?

回答

1

您是否故意嘗試混合使用兩種技術? SoapHeader來自傳統的ASMX技術,但OperationContract來自WCF。

要在WCF中使用標題,您需要使用消息合約,它可以包含標題部分以及正文部分。

1

我認爲你需要從OperationContract中分離WebMethod。

如果目標是對Web服務和WCF服務使用相同的方法,那麼您需要將該方法的副本移動到單獨的asmx中。

相關問題