Почему сервис soap возвращает текст / html вместо текста / html? - PullRequest
0 голосов
/ 18 марта 2020

Я создаю консольное приложение в C# для использования веб-службы SOAP, созданной в JAVA клиентом, но проблема в методе put или get: я получил текст / html вместо текста / xml , С клиентом все хорошо после многих тестов. Впервые, я думаю, это проблема с отсутствующим сертификатом, я установил сертификат, полученный от клиента, и добавил этот код, чтобы установить его в своем коде так:

var x509Store = new X509Store(StoreName.My, StoreLocation.LocalMachine);

x509Store.Open(OpenFlags.ReadOnly);

var thumbprint = "1f34b7d3cbf81152530bbffbb0dcff1602b9134e";

var x509CertificateCollection = x509Store.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, false);

X509Certificate2 cert = null;

if (x509CertificateCollection != null && x509CertificateCollection.Count > 0)
{
    foreach (X509Certificate2 x509Certificate in x509CertificateCollection)
    {
        cert = x509Certificate;
    }
}
else
{
    Console.WriteLine($"Certificate with serial number {thumbprint} not found.");
}

x509Store.Close();

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServiceReferenceMessageReceiver.MessageReceiverClient client = new ServiceReferenceMessageReceiver.MessageReceiverClient();
client.ClientCredentials.ClientCertificate.Certificate = cert;

и это конфигурация в приложении. config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
  </startup>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="MessageReceiverPortBinding" />
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://prod.service.com:80/service/MessageReceiverService"
        binding="basicHttpBinding" bindingConfiguration="MessageReceiverPortBinding"
        contract="ServiceReferenceMessageReceiver.MessageReceiver"
        name="MessageReceiverPort">
       <headers>
         <SOAPAction />
       </headers>
      </endpoint>
    </client>
  </system.serviceModel>

</configuration>

Я не знаю, в чем проблема. Может быть, я что-то пропустил, но мне все кажется правильным.

...