小编Tom*_*cat的帖子

WCF - BasicHttpBinding,没有可用的用户名和/或密码,name:null,password:null

我正在尝试使用通过用户/通行证保护的第三方Web服务.我相信我已经完成了验证和设置用户并传递所需的内容,但它似乎没有将它们包含在http标头或其他内容中......

试图打电话时;

nameList.AddRange(service.getBlobNameByIdAndSectionId(section, id))
Run Code Online (Sandbox Code Playgroud)

我收到这个错误;

No user name and/or password is available, name: null, password: null
Run Code Online (Sandbox Code Playgroud)

完整代码:

Private Function GetVendorService() As Services.ServiceClient
    Dim binding As New BasicHttpBinding(BasicHttpSecurityMode.Transport)

    binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName
    binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic
    Dim ea As New EndpointAddress(GetVendorServiceURL())

    Dim service As New Services.ServiceClient(binding, ea)
    service.ClientCredentials.UserName.UserName = "user"
    service.ClientCredentials.UserName.Password = "password"

    Return service

End Function

Public Function GetVendorServiceURL() As String
    Select Case Informix.HostType
        Case HostServerType.Stage
            Return "https://url-s.net:8443/cxf/Service/v1/ws"
        Case HostServerType.Dev
            Return "https://url-d.net:8443/cxf/Service/v1/ws"
        Case Else 'Live
            Return "https://url.net:8443/cxf/Service/v1/ws"
    End Select
End Function

Private …
Run Code Online (Sandbox Code Playgroud)

vb.net wcf web-services

7
推荐指数
1
解决办法
2921
查看次数

在内联if语句中将变量设置为null值

我正在尝试使用以下代码检查a DBNull,如果是,则将变量设置为空,如果不是则为短.问题是它未能将变量设置为Nothing并将其设置为a 0.谁知道为什么?

variable = If(currentRow.Item("variable") Is DBNull.Value,
    Nothing, CShort(currentRow.Item("variable")))
Run Code Online (Sandbox Code Playgroud)

vb.net

2
推荐指数
1
解决办法
2575
查看次数

标签 统计

vb.net ×2

wcf ×1

web-services ×1