我有一个错误:
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我有点困惑。我怎么才能让它工作呢?
发布于 2011-12-16 00:53:31
您是否有意将两种技术混合在一起?SoapHeader来自遗留的ASMX技术,而OperationContract来自WCF。
要在WCF中使用标头,您需要使用消息约定,它可以包含标头部分和正文部分。
发布于 2011-12-16 00:37:12
我认为您需要将WebMethod与OperationContract分开。
如果目标是对Web服务和WCF服务使用相同的方法,则需要将该方法的副本移动到单独的asmx中。
https://stackoverflow.com/questions/8523180
复制相似问题