1

エラーがあります:

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

少し混乱しています。どうすればそれを機能させることができますか?

4

2 に答える 2

1

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

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

于 2011-12-15T16:37:12.177 に答える
1

意図的に 2 つの技術を混ぜようとしたのですか? SoapHeader従来の ASMX テクノロジからのものOperationContractですが、WCF からのものです。

WCF でヘッダーを使用するには、メッセージ コントラクトを使用する必要があります。メッセージ コントラクトには、ヘッダー パーツとボディ パーツを含めることができます。

于 2011-12-15T16:53:31.097 に答える