WCF - Web服务不安全或错误安全的故障

时间:2013-04-23 16:59:20

标签: .net vb.net wcf service-reference

我正在尝试在我的VB.Net应用中使用安全的第三方Web服务(我无法控制),并且在尝试调用该服务时出现以下错误:

  

从另一方收到了无担保或不正确安全的故障。请参阅内部FaultException以获取故障代码和详细信息。

内部例外:

  

{“MustUnderstand标题:{{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}安全性”未被理解。“}

通过用户/通行证和证书保护服务。我通过wsdl创建了WCF服务引用就好了,下面是我用来设置服务的代码。我对网络服务的经验很少,而且我不知道该尝试什么。此外,如果有任何帮助,我使用的是.NET 3.5。代码在行上抛出异常;

nameList.AddRange(service.getBlobNameByIdAndSectionId(section, id))

完整代码:

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

    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 Function GetPdfListById(ByVal Id As Integer, ByVal Section As SectionId) As List(Of Services.blobName)
    Dim service As Services.ServiceClient = GetVendorService()
    Dim nameList As New List(Of Services.blobName)
    service.Open()
    nameList.AddRange(service.getBlobNameByIdAndSectionId(section, id))
    service.Close()
    Return nameList
End Function

App.config中:

<system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="ServiceSoapBinding" closeTimeout="00:01:00"
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
      maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
      useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="Transport">
        <transport clientCredentialType="None" proxyCredentialType="None"
          realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>
    <binding name="ServiceSoapBinding1" closeTimeout="00:01:00"
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
      maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
      useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None"
          realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<client>
  <endpoint address="https://url-d.menards.net:8443/cxf/Service/v1/ws"
    binding="basicHttpBinding" bindingConfiguration="ServiceSoapBinding"
    contract="Services.Service"
    name="ServiceSoapPort" />
</client>

0 个答案:

没有答案