简体   繁体   English

将WSE客户端迁移到WCF-如何替换SecurityPolicyAssertion和UsernameToken?

[英]Migrating WSE Client to WCF - how to replace SecurityPolicyAssertion and UsernameToken?

I have a web service implemented in Java that is currently being invoked by a WSE 3.0 client, and I would like to migrate from WSE to WCF. 我有一个用Java实现的Web服务,当前正在由WSE 3.0客户端调用,我想从WSE迁移到WCF。 Using the standard tools, I have created a client that can invoke the web service, but it returns a SoapException with a message of "Required parameter value is missing". 使用标准工具,我创建了一个可以调用Web服务的客户端,但是它返回一个SoapException消息,消息为“缺少必需的参数值”。 The web service uses HTTPS and requires a username & password to be provided. 该Web服务使用HTTPS,并且需要提供用户名和密码。 In the existing WSE client code, the credentials area supported by subclassing SecurityPolicyAssertion and SendSecurityFilter , as follows: 在现有的WSE客户端代码中,子类化SecurityPolicyAssertionSendSecurityFilter所支持的凭据区域如下:

            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

These classes are applied to the generated proxy class in the client as follows: 这些类将应用于客户端中生成的代理类,如下所示:

                // 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);

What I've found is that if I edit the WSE client code to remove the line objListSvc.SetPolicy(objPolicy) , I get the same error message of "Required parameter value is missing". 我发现的是,如果我编辑WSE客户端代码以删除objListSvc.SetPolicy(objPolicy)行, 则会收到相同的错误消息:“缺少必需的参数值”。

What is the equivalent WCF configuration/code to match the WSE code above that configures the Username and Password for this web service? 与上面为该Web服务配置用户名和密码的WSE代码匹配的等效WCF配置/代码是什么? The WCF configuration being used is the default that was generated: 使用的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>

Thanks in advance 提前致谢

It is hard to tell without a sample of how your SOAP message from WSE3 looks on the wire. 没有样本,很难说出来自WSE3的SOAP消息如何在线呈现。 Try to get one via Fiddler and publish it here. 尝试通过Fiddler获得一个并在此处发布。

Generally if you use SSL try something like this: 通常,如果您使用SSL,请尝试以下操作:

<bindings>
        <basicHttpBinding>
            <binding name="NewBinding0">
                <security mode="TransportWithMessageCredential " />
            </binding>
        </basicHttpBinding>
</bindings>

If you do not use ssl try CUB . 如果不使用ssl,请尝试CUB

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 WCF 客户端服务中实现 WS-security(时间戳、用户名令牌、签名) - How do I implement WS-security in WCF client service (timestamp, usernametoken, signature) 如何使WCF客户端符合特定的WS-Security - 签署UsernameToken和SecurityTokenReference - How to make WCF Client conform to specific WS-Security - sign UsernameToken and SecurityTokenReference 将WSE3 Web服务客户端代码转换为WCF - Convert WSE3 Web Service Client Code to WCF (尝试)从WSE 3.0迁移到WCF以获取客户端代码 - (Attempting to) migrate from WSE 3.0 to WCF for client code WCF - UsernameToken 的设置策略 - WCF - Setting Policy for UsernameToken WCF:将Nonce添加到UsernameToken - WCF: Adding Nonce to UsernameToken 如何使用.net webservices wse或wcf创建安全的SOAP主体? - How to create secure SOAP body using .net webservices wse or wcf? Wcf 服务服务器 - 使用 usernametoken 进行身份验证 - Wcf service server - authentication with usernametoken 使用 WS-Security UsernameToken PasswordDigest 身份验证方案使用 Axis 2 Web 服务的 WCF 客户端出错 - Error in WCF client consuming Axis 2 web service with WS-Security UsernameToken PasswordDigest authentication scheme WCF 客户端到 WSE 3.0 服务异常:CWWSS7310E:XML 加密信息 [.....] - WCF Client to WSE 3.0 service Exception: CWWSS7310E: XML encryption information[.....]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM