Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net WCF-Web服务不安全或安全性不正确故障_.net_Vb.net_Wcf_Service Reference - Fatal编程技术网

.net WCF-Web服务不安全或安全性不正确故障

.net WCF-Web服务不安全或安全性不正确故障,.net,vb.net,wcf,service-reference,.net,Vb.net,Wcf,Service Reference,我正在尝试在我的VB.Net应用程序中使用安全的第三方web服务(我无法控制),并且在尝试调用该服务时出现以下错误: 从另一方收到未担保或未正确担保的故障。有关故障代码和详细信息,请参见内部FaultException 内部异常: {“MustUnderstand头:[{}安全性]未被理解。”} 该服务通过用户/通行证和证书进行保护。我通过wsdl创建了WCF服务引用,下面是我用来设置服务的代码。我对web服务几乎没有经验,我也不知道该尝试什么。此外,我正在使用.NET3.5,如果这有什么帮助的

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

从另一方收到未担保或未正确担保的故障。有关故障代码和详细信息,请参见内部FaultException

内部异常:

{“MustUnderstand头:[{}安全性]未被理解。”}

该服务通过用户/通行证和证书进行保护。我通过wsdl创建了WCF服务引用,下面是我用来设置服务的代码。我对web服务几乎没有经验,我也不知道该尝试什么。此外,我正在使用.NET3.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>


给你的问题一个有意义的标题tomcat,今天在上创建的还有多少其他问题也是关于“WCF-Web服务”的?WCF默认将MustUnderstand标题设置为true/1。我的直觉是,要么服务器不理解您的WCF头,要么您需要将MustUnderstand头设置为false/0。不过,我不完全确定如何在WCF客户端实现这一点,这就是为什么这只是一个评论,而不是一个答案。