1

感谢多年来提供的所有帮助 - 我从来没有遇到过需要发帖的问题,因为大多数事情都已经得到解答!可惜我终于有...

使用需要在 SOAP 标头中使用非常明确的标记的 Web 服务,如下所示:

<soapenv:header>
<Authentication xmlns="...">12345</Authentication>
</soapenv:header>

为了实现这一点,我试图在我的代理上使用 (New InstanceContext(Me)) 声明,但 VB 2010 Express 不允许它,我无处可以看到为什么......代码如下:

Imports System.ServiceModel
Imports System.ServiceModel.Channels

Private Sub GoXSQ_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GoXSQ.Click
If My.Settings.XSQ <> "" Then
        Dim XSQPService As New XSQ_Proxy.XsquareProxyService(New InstanceContext(Me))
        XSQPService.Url = "http://" + My.Settings.XSQ + ":9004/XSquareProxyService"
        Dim token As String = ""
        Try
            token = XSQPService.Authenticate(My.Settings.XSQUser, My.Settings.XSQPass)
        Catch ex As Exception
            SB.AppendText(Now() & " - Error communicating with XSQ API - " & ex.Message & " - " & ex.InnerException.ToString + Environment.NewLine)
        End Try
        If token <> "" And token > "000000" Then
            SB.AppendText(Now() & " - Token received: " & token + Environment.NewLine)
            '<!--- Insert XSQ process code here! ---!>
            Using scope As New OperationContextScope(XSQPService.InnerChannel)
                If Not OperationContext.Current.OutgoingMessageHeaders.FindHeader("Authentication", "http://www.evs.tv/XMLSchema/Authentication/") = -1 Then
                    OperationContext.Current.OutgoingMessageHeaders.RemoveAt(OperationContext.Current.OutgoingMessageHeaders.FindHeader("Authentication", "http://www.evs.tv/XMLSchema/Authentication/"))
                End If
                Dim header As MessageHeader = MessageHeader.CreateHeader("Authentication", "http://www.evs.tv/XMLSchema/Authentication/", token)
                OperationContext.Current.OutgoingMessageHeaders.Add(header)
                Dim jobsrunning = XSQPService.GetMachines()
                For Each job In jobsrunning
                    SB.AppendText(job.Name)
                Next
            End Using
        Else
            SB.AppendText(Now() & " - XSQ API login failure - check username/password!" + Environment.NewLine)
        End If
    End If
End Sub

我收到的错误是:

Dim XSQPService As New XSQ_Proxy.XsquareProxyService(New InstanceContext(Me)) 

Public Sub New() 的参数太多

Using scope As New OperationContextScope(XSQPService.InnerChannel)

InnerChannel 不是...的成员

我猜第二个是由于第一个,但我找不到任何东西来确定为什么这个短语不起作用 - 它完全支持 .NET 4.0,这是我的编译框架!

任何帮助,将不胜感激

保罗

4

0 回答 0