无法从 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
,我无法编译将此 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使您的 NotifierAuthHeader 可序列化
Try making your your NotifierAuthHeader serializable