Q: How to pass a SAML object to do authentication in Webservice using System.ServiceModel.ClientBase I have a project that consumes a service. When I added the service reference in the solution, I noticed that the service extends the "System.Model.ClientBase" class, right?
Well, when I instantiate this service, I need to pass a SAML object in the header, to authenticate.
The problem is that I can't get it to work. Let me show my code:
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
[System.ServiceModel.MessageContractAttribute(IsWrapped=false)]
public partial class CreditApplicationRequest{
    
    [System.ServiceModel.MessageHeaderAttribute(Namespace="http://www.mycompany.com/HeaderDataXMLS")]
    public headerData headerData;

    // I inserted this one here.
    [System.ServiceModel.MessageHeaderAttribute(Namespace = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")]
    Security security;

    [System.ServiceModel.MessageBodyMemberAttribute(Name="MyRequest", Namespace="http://www.mycompany.com/types", Order=0)]
    public CreditApplicationRequestType creditApplicationRequestType;

    public CreditApplicationRequest() {
    }
    
    public CreditApplicationRequest(
        headerData headerData,
        Security security,
        CreditApplicationRequestType creditApplicationRequestType) {
        this.headerData = headerData;
        this.security = security;
        this.creditApplicationRequestType = creditApplicationRequestType;
    }
}

After that, we have:
public CreditApplicationResponseType CreditApplication(
    ref headerData headerData,
    Security security,
    CreditApplicationRequestType creditApplicationRequestType) {

        CreditApplicationRequest inValue = new CreditApplicationRequest();
        inValue.headerData = headerData;
        inValue.creditApplicationRequestType = creditApplicationRequestType;
        inValue.security = security;

        CreditApplicationResponse retVal = ((PortType (this)).CreditApplication(inValue);
        headerData = retVal.headerData;

        return retVal.SMBExistingCreditApplicationResponse1;
        }

[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
 CreditApplicationResponse CreditApplication(CreditApplicationRequest request) {
            // The error happens here
            return base.Channel.CreditApplication(request);
        }

When I try to connect, I receive the follow error message: OSB-386200: General web service security error
Any idea about this?
