2011-12-15 11 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

意図的に2つのテクノロジーをミックスしようとしましたか? SoapHeaderは従来のASMXテクノロジのものですが、OperationContractはWCFのものです。

WCFでヘッダーを使用するには、ヘッダー部分と本文部分を含むことができるメッセージ契約を使用する必要があります。

1

WebMethodとOperationContractを分離する必要があると思います。

WebサービスとWCFサービスで同じメソッドを使用するのが目的の場合は、メソッドのコピーを別のasmxに移動する必要があります。

関連する問題