2011-10-21 55 views
1

訪問類我有一個類無法從ASMX服務

Public Class NotifierAuthHeader 
    Inherits SoapHeader 

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

我在Web服務中的下列方法使用:

<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 

的問題是,我無法編譯客戶端WPF這個webservice作爲servicereference的應用程序,因爲它說我,他不知道w任何NotifierAuthHeader類。

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

//Here it says about this error 

private ServiceReference1.NotifierAuthHeader _authHdr; 

有趣的是,我可以在客戶端使用GetTestNotifierAuthHeader的方法,但類型的返回對象is..object的,不NotifierAuthHeader

可能是什麼錯我的代碼?

asmx服務是3.5 和wpf應用程序是4.0 c#。

回答

1

嘗試使你對你的NotifierAuthHeader序列化

<Serializable()>Public Class NotifierAuthHeader 
    Inherits SoapHeader 

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