Добрый день.
Никак не получается вызвать из VB6 сервис WCF c включенной windows аутентификацией. Ошибка 401 Unauthorized.
На стороне сервиса следующие настройки:
web.config:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
<services>
<service name="AmlBlServiceWithSimleTypes.AmlBlServiceSimpleT.svc">
<endpoint address="" binding="basicHttpBinding" contract="AMLServiceInterface" bindingConfiguration="AmlBlBinding">
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://testserver/AmlBlService/" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="AmlBlBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
На виртуальной директории в IIS установлена анонимная и Windows аутентификация. Анонимная нужна для инициализации сервиса в VB, когда идет обращение к wsdl.
НА стороне клиента установлена Microsoft SOAP Toolkit 3.0
Код клиента:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
Dim sReply As String
Dim clnt As New MSSOAPLib30.SoapClient30
clnt.MSSoapInit "http://testserver/amlblservicest/AmlBlServiceWithSimleTypes.AmlBlServiceSimpleT.svc?wsdl"
'clnt.ConnectorProperty("AuthUser") = ""
'clnt.ConnectorProperty("AuthPassword") = ""
clnt.ConnectorProperty("ConnectTimeout") = 3000
clnt.ConnectorProperty("Timeout") = 5000
clnt.ConnectorProperty("WinHTTPAuthScheme") = 18
sReply = clnt.SimpleTest("asdfa", 1 )
Set clnt = Nothing
MsgBox "sReply = " & sReply
Если явно не задать свойства AuthUser и AuthPassword, то
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
POST /amlblservicest/AmlBlServiceWithSimleTypes.AmlBlServiceSimpleT.svc HTTP/1.1
SOAPAction: "http://AmlOatom/AMLServiceInterface/SimpleTestRequest"
Content-Type: text/xml; charset="UTF-8"
User-Agent: SOAP Toolkit 3.0
Host: testserver
Content-Length: 514
Connection: Keep-Alive
Cache-Control: no-cache
Pragma: no-cache
<?xml version="1.0" encoding="UTF-8" standalone="no"?><SOAP-ENV:Envelope xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema" xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAPSDK4:SimpleTest xmlns:SOAPSDK4="http://AmlOatom"><SOAPSDK4:param1>asdfa</SOAPSDK4:param1><SOAPSDK4:param2>1</SOAPSDK4:param2></SOAPSDK4:SimpleTest></SOAP-ENV:Body></SOAP-ENV:Envelope>
HTTP/1.1 401 Unauthorized
Date: Thu, 27 Jan 2011 08:48:30 GMT
Server: Microsoft-IIS/6.0
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
Cache-Control: private
Content-Length: 0
POST /amlblservicest/AmlBlServiceWithSimleTypes.AmlBlServiceSimpleT.svc HTTP/1.1
SOAPAction: "http://AmlOatom/AMLServiceInterface/SimpleTestRequest"
Content-Type: text/xml; charset="UTF-8"
User-Agent: SOAP Toolkit 3.0
Host: testserver
Content-Length: 0
Connection: Keep-Alive
Cache-Control: no-cache
Pragma: no-cache
HTTP/1.1 401 Unauthorized
Date: Thu, 27 Jan 2011 08:48:30 GMT
Server: Microsoft-IIS/6.0
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
Cache-Control: private
Content-Length: 0
POST /amlblservicest/AmlBlServiceWithSimleTypes.AmlBlServiceSimpleT.svc HTTP/1.1
SOAPAction: "http://AmlOatom/AMLServiceInterface/SimpleTestRequest"
Content-Type: text/xml; charset="UTF-8"
User-Agent: SOAP Toolkit 3.0
Host: testserver
Content-Length: 0
Connection: Keep-Alive
Cache-Control: no-cache
Pragma: no-cache
HTTP/1.1 401 Unauthorized
Date: Thu, 27 Jan 2011 08:48:30 GMT
Server: Microsoft-IIS/6.0
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
Cache-Control: private
Content-Length: 0
А если задать свойства AuthUser и AuthPassword, то:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
POST /amlblservicest/AmlBlServiceWithSimleTypes.AmlBlServiceSimpleT.svc HTTP/1.1
SOAPAction: "http://AmlOatom/AMLServiceInterface/SimpleTestRequest"
Content-Type: text/xml; charset="UTF-8"
User-Agent: SOAP Toolkit 3.0
Host: testserver
Content-Length: 514
Connection: Keep-Alive
Cache-Control: no-cache
Pragma: no-cache
<?xml version="1.0" encoding="UTF-8" standalone="no"?><SOAP-ENV:Envelope xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema" xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAPSDK4:SimpleTest xmlns:SOAPSDK4="http://AmlOatom"><SOAPSDK4:param1>asdfa</SOAPSDK4:param1><SOAPSDK4:param2>1</SOAPSDK4:param2></SOAPSDK4:SimpleTest></SOAP-ENV:Body></SOAP-ENV:Envelope>
HTTP/1.1 401 Unauthorized
Date: Thu, 27 Jan 2011 10:08:10 GMT
Server: Microsoft-IIS/6.0
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
Cache-Control: private
Content-Length: 0
POST /amlblservicest/AmlBlServiceWithSimleTypes.AmlBlServiceSimpleT.svc HTTP/1.1
SOAPAction: "http://AmlOatom/AMLServiceInterface/SimpleTestRequest"
Content-Type: text/xml; charset="UTF-8"
User-Agent: SOAP Toolkit 3.0
Host: testserver
Connection: Keep-Alive
Cache-Control: no-cache
Pragma: no-cache
Authorization: Negotiate TlRMTVNTUAABAAAAB4IIogAAAAAAAAAAAAAAAAAAAAAFASgKAAAADw==
Content-Length: 0
HTTP/1.1 401 Unauthorized
Content-Length: 1539
Content-Type: text/html
Server: Microsoft-IIS/6.0
WWW-Authenticate: Negotiate TlRMTVNTUAACAAAADgAOADgAAAAFgomiL6YwBVIBtQQAAAAAAAAAAHgAeABGAAAABQLODgAAAA9EAEUAVgBDAE8AUgBQAAIADgBEAEUAVgBDAE8AUgBQAAEAEgBTAFQAQQBOAEQATQBXAC0AMwAEABgAYwBvAHIAcAAuAGQAZQB2AC4AdgB0AGIAAwAsAFMAdABhAG4AZABNAFcALQAzAC4AYwBvAHIAcAAuAGQAZQB2AC4AdgB0AGIAAAAAAA==
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
Date: Thu, 27 Jan 2011 10:08:10 GMT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>You are not authorized to view this page</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">
<STYLE type="text/css">
BODY { font: 8pt/12pt verdana }
H1 { font: 13pt/15pt verdana }
H2 { font: 8pt/12pt verdana }
A:link { color: red }
A:visited { color: maroon }
</STYLE>
</HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD>
<h1>You are not authorized to view this page
</h1>
You do not have permission to view this directory or page using the credentials that you supplied.
<hr>
<p>Please try the following:</p>
<ul>
<li>Contact the Web site administrator if you believe you should be able to view this directory or page.</li>
<li>Click the <a href="javascript:location.reload()">Refresh</a> button to try again with different credentials.</li>
</ul>
<h2>HTTP Error 401.1 - Unauthorized: Access is
denied due to invalid credentials.<br>Internet Information Services (IIS)</h2>
<hr>
<p>Technical Information (for support personnel)</p>
<ul>
<li>Go to <a href="http://go.microsoft.com/fwlink/?linkid=8180">Microsoft Product Support Services</a> and perform a title search for the words <b>HTTP</b> and <b>401</b>.</li>
<li>Open <b>IIS Help</b>, which is accessible in IIS Manager (inetmgr),
and search for topics titled <b>Authentication</b>, <b>Access Control</b>, and <b>About Custom Error Messages</b>.</li>
</ul>
</TD></TR></TABLE></BODY></HTML>
POST /amlblservicest/AmlBlServiceWithSimleTypes.AmlBlServiceSimpleT.svc HTTP/1.1
SOAPAction: "http://AmlOatom/AMLServiceInterface/SimpleTestRequest"
Content-Type: text/xml; charset="UTF-8"
User-Agent: SOAP Toolkit 3.0
Host: testserver
Authorization: Negotiate TlRMTVNTUAADAAAAGAAYAHYAAACoAKgAjgAAAA4ADgBIAAAACgAKAFYAAAAWABYAYAAAAAAAAAA2AQAABYKIogUBKAoAAAAPRABFAFYAQwBPAFIAUABpAGoAcAAxADUAUABMAFUASAAtADcAMAAwADAAMwAxAKFx7X/EcVcLmwxLT6arW73p8ngu8hADhGxjaIU4yvggIfzcxdkjz7gBAQAAAAAAAHvPhxoKvssB6fJ4LvIQA4QAAAAAAgAOAEQARQBWAEMATwBSAFAAAQASAFMAVABBAE4ARABNAFcALQAzAAQAGABjAG8AcgBwAC4AZABlAHYALgB2AHQAYgADACwAUwB0AGEAbgBkAE0AVwAtADMALgBjAG8AcgBwAC4AZABlAHYALgB2AHQAYgAAAAAAAAAAAA==
Connection: Keep-Alive
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 514
<?xml version="1.0" encoding="UTF-8" standalone="no"?><SOAP-ENV:Envelope xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema" xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAPSDK4:SimpleTest xmlns:SOAPSDK4="http://AmlOatom"><SOAPSDK4:param1>asdfa</SOAPSDK4:param1><SOAPSDK4:param2>1</SOAPSDK4:param2></SOAPSDK4:SimpleTest></SOAP-ENV:Body></SOAP-ENV:Envelope>
HTTP/1.1 200 OK
Date: Thu, 27 Jan 2011 10:08:10 GMT
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
Content-Length: 213
Cache-Control: private
Content-Type: text/xml; charset=utf-8
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><SimpleTestResponse xmlns="http://AmlOatom"><param3 xmlns="">param1=, param2=0</param3></SimpleTestResponse></s:Body></s:Envelope>
Складывается такое впечатление, что по какой то причине клиент просто не передает свои Credentials.