Ошибка HTTP 400 при вызове метода веб-сервиса - PullRequest
0 голосов
/ 08 марта 2019

Я использую веб-сервис в своем приложении .net, и вызов метода на веб-сервисе вызывает следующую ошибку:

System.ServiceModel.ProtocolException
  HResult=0x80131501
  Message=The remote server returned an unexpected response: (400) Bad Request.
  Source=mscorlib
  StackTrace:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

Код для вызова веб-службы следующий:

    testws.B2BServiceClient b2BServiceClient = new testws.B2BServiceClient();
    testws.CancelRequest cancelRequest = new testws.CancelRequest();

    cancelRequest = new testws.CancelRequest
    {
        Service_ID = "test_service_id",
        Provider_Ref = "test_provider_ref"
    };

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;

    b2BServiceClient.ClientCredentials.UserName.UserName = "myusername";
    b2BServiceClient.ClientCredentials.UserName.Password = "mypasssword";
    testws.Response response = b2BServiceClient.CancelService(cancelRequest);

Вот фрагмент из web.config

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_testservice">
          <security mode="Transport">
          </security>          
        </binding>
      </basicHttpBinding>      
    </bindings>
    <client>
      <endpoint address="https://endpointurl" binding="basicHttpBinding"
        bindingConfiguration="BasicHttpBinding_testservice" contract="testws.testservice" name="BasicHttpBinding_testservice"/>
    </client>
  </system.serviceModel>

Также я попытался сделать запрос от SoapUI следующим образом:

   <soapenv:Header>
    <wsse:Security SOAP-ENV:mustUnderstand = "1" xmlns:wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
      <wsse:UsernameToken xmlns:wsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
        <wsse:Username>myusername</wsse:Username>
        <wsse:Password Type = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">mypassword</wsse:Password>
      </wsse:UsernameToken>
    </wsse:Security>
  </SOAP-ENV:Header>

   <soapenv:Body>
      <tem:CancelService>
         <!--Optional:-->
         <tem:request>
            <!--Optional:-->
            <mod:Service_ID>test_service_id</mod:Service_ID>
            <mod:Provider_Ref>test_provider_ref</mod:Provider_Ref>
         </tem:request>
      </tem:CancelService>
   </soapenv:Body>
</soapenv:Envelope>

Выполнение этого в SoapUI дает мне внутреннюю ошибку сервера HTTP / 1.1 500

, что в основном означает, что запрос через SoapUI попадает на сервер. Что мне нужно сделать, чтобы получить хотя бы ту же ошибку в моем приложении .net.

Кроме того, есть ли способ перехватить исходящий запрос мыла в .net?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...