none
XML security namespace from code RRS feed

  • Question

  • Hi,

    I am using 3rd party service URL from my WCF code and defining everything from code  and database, not from web.config. Defining HTTPBinding and binding elements also from code. 

     BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
                basicHttpBinding.Security.Mode = BasicHttpSecurityMode.TransportWithMessageCredential;
                basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
                basicHttpBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
                basicHttpBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;

                     BindingElementCollection _bindingElements = _myClient.Endpoint.Binding.CreateBindingElements();
                    _bindingElements.Find<SecurityBindingElement>().IncludeTimestamp = false;
                    _myClient.Endpoint.Binding = new CustomBinding(_bindingElements);

    While executing when i trace the XML it is as below. Highlighted bold part in security name space is taking by default as oasis which is not working for me. If needs to be changed to http://schemas.xmlsoap.org/ws/2003/06/secext" to get response. 

    How to change it? please help me

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <s:Header>
    <VsDebuggerCausalityData

    xmlns="http://schemas.microsoft.com/vstudio/diagnostics/servicemodelsink">uIDPo5TOJ2Q58qNIi1IeasoccCoAAAAAmQ7W7B5fYEmXWhpPpmkTt5pjD8GGqodIgjeeX+Rgg7IACQAA</VsDebuggerCausalityData>
    <o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
    <o:UsernameToken u:Id="uuid-c65ac0e5-f772-47bb-b664-7902d4fc1b6f-1">
    <o:Username>Username</o:Username>
    <o:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Password</o:Password>
    </o:UsernameToken>
    </o:Security>
    </s:Header>
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

    Please help me.

    Thank you...

     
    Thursday, September 8, 2016 8:33 AM

Answers

  • Hi 123tej,

    >> I am using 3rd party service URL from my WCF code and defining everything from code  and database, not from web.config.

    Do you know how 3<sup>rd</sup> party service implement? Could you add this service reference to your project?

    Based on your code, it seems you create custom binding and service uses TransportWithMessage. How did you set custom binding elements? I suggest you try WSHttpBinding.

    I found XML header security namespace from code in StackOverFlow, have you tried WCF Client - How to process or ignore a MustUnderstand header element?

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, September 9, 2016 6:24 AM