0

現在 WSE 3.0 クライアントによって呼び出されている Java で実装された Web サービスがあり、WSE から WCF に移行したいと考えています。標準ツールを使用して、Web サービスを呼び出すことができるクライアントを作成しましたが、「必要なパラメーター値がありません」というメッセージとともに SoapException が返されます。Web サービスは HTTPS を使用し、ユーザー名とパスワードを提供する必要があります。既存の WSE クライアント コードでは、次のようにSecurityPolicyAssertionおよびSendSecurityFilterをサブクラス化することによって資格情報領域がサポートされます。

            public class UTClientAssertion : SecurityPolicyAssertion
            {
                public UTClientAssertion()
                {
                }

                public override SoapFilter CreateClientOutputFilter(FilterCreationContext context)
                {
                    return new ClientOutputFilter(this, context);
                }

                public override SoapFilter CreateClientInputFilter(FilterCreationContext context)
                {
                    // we don't provide ClientInputFilter
                    return null;
                }

                public override SoapFilter CreateServiceInputFilter(FilterCreationContext context)
                {
                    // we don't provide any processing for web service side
                    return null;
                }

                public override SoapFilter CreateServiceOutputFilter(FilterCreationContext context)
                {
                    // we don't provide any processing for web service side
                    return null;
                }

                #region ClientOutputFilter
                class ClientOutputFilter : SendSecurityFilter
                {
                    public ClientOutputFilter(UTClientAssertion parentAssertion, FilterCreationContext context)
                        : base(parentAssertion.ServiceActor, false, parentAssertion.ClientActor)
                    {
                    }

                    public override void SecureMessage(SoapEnvelope envelope, Security security)
                    {
                        UsernameToken token = new UsernameToken("UserName", "Password", PasswordOption.SendPlainText);
                        security.Tokens.Add(token);
                        security.MustUnderstand = false;
                    }
                }
                #endregion

これらのクラスは、クライアントで生成されたプロキシ クラスに次のように適用されます。

                // Create the web service client
                ListService objListSvc = new ListService();

                //code to set up the security policy and user assertion
                UTClientAssertion objAssertion = new UTClientAssertion();

                // create policy, add the assertion, and set it on the web service
                Policy objPolicy = new Policy();
                objPolicy.Assertions.Add(objAssertion);
                objListSvc.SetPolicy(objPolicy);

私が見つけたのは、WSE クライアント コードを編集してobjListSvc.SetPolicy(objPolicy)の行を削除すると、「必要なパラメーター値がありません」という同じエラー メッセージが表示されることです。

この Web サービスのユーザー名とパスワードを構成する、上記の WSE コードと一致する同等の WCF 構成/コードは何ですか? 使用されている WCF 構成は、生成された既定値です。

        <basicHttpBinding>
            <binding name="ListBinding" 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>

前もって感謝します

4

1 に答える 1