C# クライアントからの Web サービス呼び出しで問題が発生しています。時折、次のエラーが返されます。
WWW-Authenticate: Basic realm="[SomeRealm]"'. --->
System.ServiceModel.Security.MessageSecurityException:
The HTTP request is unauthorized with client authentication scheme 'Digest'.
The authentication header received from the server was 'Digest realm="[SomeRealm]",
nonce="00000717Y382188758809db0bcc622bdf37def3deabb93", stale=FALSE, qop="auth"
WWW-Authenticate: Basic realm="[SomeRealm]"'. --->
System.Net.WebException: The remote server returned an error: (401) Unauthorized.
しかし、その理由がわかりません。再現が非常に難しく、デバッグが非常に困難です。ほとんどの場合、Web サービスへの呼び出しは問題なく機能します。なぜこれが起こるのか誰にも分かりますか?または、デバッグして問題に関する詳細情報を取得する方法に関するヒントはありますか?
アップデート:
わかりましたので、フィドラーを使用して行われている通信を調べてみましたが、賢くはなりませんでした。
これは有効なリクエスト/チャレンジ/リクエスト/レスポンスです
リクエスト
POST http://192.168.1.3/api/services HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8;
action="http://www.domain.com/api/ws/event1/GetScheduledEvents"
Host: 192.168.1.3
Content-Length: 482
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
チャレンジ
HTTP/1.1 401 Unauthorized
Date: Wed, 14 Aug 2013 07:45:49 GMT
Accept-Ranges: bytes
Connection: close
WWW-Authenticate: Digest realm="[SomeRealm]",
once="00025a89Y1892894c7fb9fe5f9de425b40c72d72de3227", stale=FALSE, qop="auth"
WWW-Authenticate: Basic realm="[SomeRealm]"
Content-Length: 180
Content-Type: text/html; charset=ISO-8859-1
<HTML><HEAD><TITLE>401 Unauthorized</TITLE></HEAD>
<BODY><H1>401 Unauthorized</H1>
Your client does not have permission to get URL /api/services from this server.
</BODY></HTML>
リクエスト
POST http://192.168.1.3/api/services HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8; action="http://www.domain.com/api/ws/event1/GetScheduledEvents"
Accept-Encoding: gzip, deflate
Authorization: Digest username="UserName",realm="[SomeRealm]",nonce="00025a89Y1892894c7fb9fe5f9de425b40c72d72de3227",uri="/api/services",cnonce="abff70e14c8f89b09abac9eaaa9de8ce",nc=00000001,qop="auth",response="df71769f9fb2bb5e1396546b7422d5fd"
Host: 192.168.1.3
Content-Length: 482
Connection: Keep-Alive
応答
HTTP/1.1 200 OK
Authentication-Info: qop=auth, rspauth="51832dfe63819c551bf666409f58b08c", cnonce="abff70e14c8f89b09abac9eaaa9de8ce", nc=00000001
Server: gSOAP/2.7
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 3752
Connection: close
そして、これは失敗したリクエスト/チャレンジ/リクエスト/レスポンスの1つです
リクエスト
POST http://192.168.1.3/api/services HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8; action="http://www.domain.com/api/ws/event1/GetScheduledEvents"
Host: 192.168.1.3
Content-Length: 482
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
チャレンジ
HTTP/1.1 401 Unauthorized
Date: Wed, 14 Aug 2013 07:45:49 GMT
Accept-Ranges: bytes
Connection: close
WWW-Authenticate: Digest realm="[SomeRealm]", nonce="00025a89Y3757607d2e481c5c24cb20f1a46b129a37218", stale=FALSE, qop="auth"
WWW-Authenticate: Basic realm="[SomeRealm]"
Content-Length: 180
Content-Type: text/html; charset=ISO-8859-1
<HTML><HEAD><TITLE>401 Unauthorized</TITLE></HEAD>
<BODY><H1>401 Unauthorized</H1>
Your client does not have permission to get URL /api/services from this server.
</BODY></HTML>
リクエスト
POST http://192.168.1.3/api/services HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8; action="http://www.domain.com/api/ws/event1/GetScheduledEvents"
Accept-Encoding: gzip, deflate
Authorization: Digest username="UserName",realm="[SomeRealm]",nonce="00025a89Y3757607d2e481c5c24cb20f1a46b129a37218",uri="/api/services",cnonce="9daae13f56820d9edf12cbf7e41f894b",nc=00000001,qop="auth",response="18d885af71eb74d1476da0f3668bf00e"
Host: 192.168.1.3
Content-Length: 482
Connection: Keep-Alive
応答
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Digest realm="[SomeRealm]", nonce="00025a89Y412766b2f55e4fc54dbd441b95cc713e08ccb", stale=FALSE, qop="auth"
WWW-Authenticate: Basic realm="[SomeRealm]"
Server: gSOAP/2.7
Content-Type: text/xml; charset=utf-8
Content-Length: 0
Connection: close