net Framework авторизованный вызов веб-службы soap - PullRequest
0 голосов
/ 11 апреля 2020

Я пытаюсь получить доступ к службе soap, для которой требуются эти заголовки

<soapenv:Header>
     <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wsswssecurity-utility-1.0.xsd">
         <wsse:UsernameToken wsu:Id="UsernameToken-134F28397E84840D3F14484484569051">
              <wsse:Username>***************************************************</wsse:Username>
              <wsse:Password Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile1.0#PasswordText'>****</wsse:Password>
         </wsse:UsernameToken>
     </wsse:Security>
 </soapenv:Header>

При импорте службы (как подключенной службы) из Visual Studio я получаю

<system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="xxxxInterfaceSoapBinding">
          <!--    WsdlImporter encountered unrecognized policy assertions in ServiceDescription 'URL-HIDDEN':    -->
          <!--    <wsdl:binding name='xxxxInterfaceSoapBinding'>    -->
          <!--        <sp:SupportingTokens xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">..</sp:SupportingTokens>    -->
          <textMessageEncoding messageVersion="Soap11" />
          <httpsTransport />
        </binding>
      </customBinding>
    </bindings>
    <client>
      <endpoint address="URL-HIDDEN"
        binding="customBinding" bindingConfiguration="xxxxInterfaceSoapBinding"
        contract="XxxxWebService.xxxx" name="xxxxPort" />
    </client>
  </system.serviceModel>

Я инициализирую службу как таковую

        client = new xxxxClient();
        client.ClientCredentials.UserName.UserName = "USERNAME";
        client.ClientCredentials.UserName.Password = "PASSWORD";

Я получаю следующую ошибку:

Exception Details: System.ServiceModel.FaultException: These policy alternatives can not be satisfied:
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}SupportingTokens
{http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702}UsernameToken

Реализовано решение, описанное здесь { ссылка }. Внедрение заголовков перед каждым вызовом, но я все еще получаю

Exception Details: System.ServiceModel.FaultException: A security error was encountered when verifying the message

У кого-нибудь есть обходной путь или он знает, что может быть причиной?

...