无法从ASMX服务访问类

时间:2011-10-21 14:49:27

标签: c# .net vb.net asmx

我有一个班级

Public Class NotifierAuthHeader
    Inherits SoapHeader

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

我在webservice中使用以下方法:

<OperationContract()><WebMethod()> _
public Function GetTestNotifierAuthHeader()
    Dim testNotifierAuthHeader as NotifierAuthHeader=new NotifierAuthHeader()

    return testNotifierAuthHeader

<SoapHeader("auth", GetType(NotifierAuthHeader), Direction:=SoapHeaderDirection.In)> _
    <OperationContract()> <WebMethod()> _
    Public Function GetUnreadInboxMessages(ByVal handlerId As Integer, ByVal customerGuid As String) As String

问题是,我无法编译具有此web服务作为服务引用的客户端WPF应用程序,因为它告诉我,他不知道任何NotifierAuthHeader类。

private ServiceReference1.Service1SoapClient _ws = new ServiceReference1.Service1SoapClient();

//Here it says about this error

private ServiceReference1.NotifierAuthHeader _authHdr;

有趣的是,我可以在客户端使用GetTestNotifierAuthHeader方法,但返回对象的类型是..object,而不是NotifierAuthHeader

我的代码有什么问题?

asmx服务是3.5 和wpf app是4.0 c#。

1 个答案:

答案 0 :(得分:1)

尝试将NotifierAuthHeader序列化

<Serializable()>Public Class NotifierAuthHeader 
    Inherits SoapHeader 

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