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. 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". The web service uses HTTPS and requires a username & password to be provided. In the existing WSE client code, the credentials area supported by subclassing SecurityPolicyAssertion and SendSecurityFilter, as follows:
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".
What is the equivalent WCF configuration/code to match the WSE code above that configures the Username and Password for this web service? The WCF configuration being used is the default that was generated:
<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