无法从 ASMX 服务访问类

发布于 2024-12-11 08:41:00 字数 1236 浏览 0 评论 0原文

我有一个

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

,我无法编译将此 webservice 作为服务引用的客户端 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 应用程序是 4.0 c#。

I have a class

Public Class NotifierAuthHeader
    Inherits SoapHeader

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

which I use in webservice in following methods:

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

    return testNotifierAuthHeader

and

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

The problem is, I can't compile client WPF application which has this webservice as servicereference, because it say me, that he doesn't know any NotifierAuthHeader class.

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

//Here it says about this error

private ServiceReference1.NotifierAuthHeader _authHdr;

Funny thing is, that I can use GetTestNotifierAuthHeader method at client, but type of return object is..object, not NotifierAuthHeader

What could be wrong with my code?

asmx service is 3.5
and wpf app is 4.0 c#.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千紇 2024-12-18 08:41:00

尝试使您的 NotifierAuthHeader 可序列化

<Serializable()>Public Class NotifierAuthHeader 
    Inherits SoapHeader 

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

Try making your your NotifierAuthHeader serializable

<Serializable()>Public Class NotifierAuthHeader 
    Inherits SoapHeader 

    Public HandlerId As Integer 
    Public Guid As Byte() 
End Class 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文