[英]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客户端代码中,子类化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
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.