これは私が現在C#のWCF Webサービスに接続している方法です。 私はこのウェブサービスを私が開発したものではないので、私はこのウェブサービスを何もコントロールしていないので、それを変更することはできません。ここで私が使用してC#コードは次のとおりです。WCF(svcutil)のC#コードを対応するSOAPエンベロープのPOSTリクエストに変換する
WSHttpBinding binding = new WSHttpBinding();
binding.Security.Mode = SecurityMode.TransportWithMessageCredential;
binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
binding.Security.Message.NegotiateServiceCredential = true;
binding.Security.Message.AlgorithmSuite = System.ServiceModel.Security.SecurityAlgorithmSuite.Default;
binding.Security.Message.EstablishSecurityContext = true;
EndpointAddress endpoint = new EndpointAddress("<address>");
fooClient client = new fooClient(binding, endpoint);
client.ClientCredentials.UserName.UserName = "the_username";
client.ClientCredentials.UserName.Password = "the_password";
//fooClient class came from running
// svcutil.exe https://<thedomain>/foo/foo.svc?wsdl
//I now work with fooClient, call methods on it, etc.
私はC#のせずにWebサービスに接続したい - 手動でSOAPエンベロープを作成し、エンドポイント上のPOSTリクエストをすることによって。資格情報が不足しているため、
POST /foo/foo.svc HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8
Host: <thedomain>
Connection: close
User-Agent: <my user agent>
Content-Length: 416
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<someWebServiceFunction xmlns="http://<thedomain>/foo/foo">
<someParameter>some parameter value</someParameter>
</someWebServiceFunction>
</soap12:Body>
</soap12:Envelope>
しかし、これは動作しません:私はこのようになりますPOSTリクエストをやってみました。 「BadContextToken」、「セキュリティコンテキストトークンが期限切れまたは有効ではありません。メッセージは処理されませんでした。」
私の質問はどのように私のSOAPエンベロープ/ HTTPリクエスト?私は(HTTPヘッダーで)承認HTTPの基本認証を試みたが、これは私に同じ "BadContextToken"エラーを与え続けている。