Я хочу использовать защищенный веб-сервис ssl на C#. Запрос выглядит следующим образом:Использование веб-службы с SSL (https) в C#
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:biw="http://tempuri.org/ws_returnTable"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
>
<soapenv:Header>
<wsse:Security>
<wsse:UsernameToken>
<wsse:Username>sasdemo</wsse:Username>
<wsse:Password>sasch.111</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<biw:meansclass />
</soapenv:Body>
</soapenv:Envelope>
Декларация конечной точки в WSDL выглядит следующим образом:
<wsdl:service name="meansclass">
<wsdl:port binding="tns:meansclassSoapBinding" name="meansclassPort">
<soap:address location="https://sas.ssz.intra.stzh.ch:8443/SASBIWS/services/Shared%20Data/ws/meansclass" />
</wsdl:port>
</wsdl:service>
app.config выглядит следующим образом:
<bindings>
<basicHttpBinding>
<binding name="meansclassSoapBinding" 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>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://localhost:8443/SASBIWS/services/Shared%20Data/ws/meansclass"
binding="basicHttpBinding" bindingConfiguration="meansclassSoapBinding"
contract="ServiceReference1.meansclassPortType" name="meansclassPort" />
</client>
Я пытался получить доступ к веб с кодом C#:
var service = new meansclassPortTypeClient();
service.ClientCredentials.UserName.UserName = "username";
service.ClientCredentials.UserName.Password = "password";
var test = service.meansclass();
Но всегда есть исключение, вызванное средством класса(). На немецком языке он гласит:
Исключение типа «Аутентификация клиента» (...) Отсутствует контекст безопасности.
У меня много googled, но я не узнал, что я делаю неправильно. Как я могу сделать такой «контекст безопасности»? Или что не так?
Я думаю, вам нужно установить –