This discussion is archived
1 Reply Latest reply: Aug 15, 2012 1:33 PM by 662736 RSS

c# add security header (error Missing <wsse:Security ) or to do stateless

924210 Newbie
Currently Being Moderated
I've seen this question in multiple ways, the problem is that by default we can't change the soap message to add the security token like it says in the oracle pdf. so after a lot of trying i found the way to do it but you won't like it.

this is a bad solution because every time i update the service reference it blows up and i have to change the Reference.cs again, but i found nothing better.


First download the microsoft WEB SERVICES ENHANCEMENTS (WSE 2.0 or 3.0). this will give you the namespace to create the UsernameToken and the object you'll inherit on the reference.cs

You need to make manual changes to the service reference.cs (i don't like it either). change the inherited namespace from "System.Web.Services.Protocols.SoapHttpClientProtocol" to "Microsoft.Web.Services3.WebServicesClientProtocol"

This will give you access to the security header to add the token like this:

CascadingPicklistService service = new CascadingPicklistService();
CascadingPicklistRead_Input input = new CascadingPicklistRead_Input();
UsernameToken userToken = new UsernameToken(username, password, PasswordOption.SendPlainText);
CascadingPicklistRead_Output output;

service.RequestSoapContext.Security.Tokens.Add(userToken);
input.CascadingPicklistSet = new CascadingPicklistSetQuery();
input.CascadingPicklistSet.ObjectName = "Service Request";
output = service.CascadingPicklistRead(input);

//Indexed Pick 0 is the case type picklist
List<PicklistValueAssociationsData> lst =
output.ListOfCascadingPicklistSet[0].ListOfCascadingPicklist.Where(prop => prop.ParentPicklist == "Indexed Pick 0").FirstOrDefault().ListOfPicklistValueAssociations.ToList();
PicklistValueAssociationsData listData = lst.Where(pp => pp.ParentPicklistValue == parentValue).FirstOrDefault();
if (listData != null)
{
return listData.RelatedPicklistValue.ToDictionary(a => a, b => b);
}
else
{
List<PicklistValue> parentPick = GetPickList(PickListRecordType.Case, PickListType.Reason);
return (from p in parentPick select new { p.Code, p.DisplayValue }).Distinct().ToDictionary(k => k.Code, v => v.DisplayValue);
}
  • 1. Re: c# add security header (error Missing <wsse:Security ) or to do stateless
    662736 Newbie
    Currently Being Moderated
    If you are using .NET 4.0 or higher you are better off using WCF. If you generate your proxy classes using "svcutil.exe" there will be a class called "CascadingPicklistServiceClient" that inherits from "ClientBase<TChannel>". To set credentials, do the following:

    CascadingPicklistServiceClient picklistService = new CascadingPicklistServiceClient();
    picklistService.ClientCredentials.UserName.UserName = "uuuuuuu";
    picklistService.ClientCredentials.UserName.Password = "ppppppp";

    The reason I recommend .NET 4.0 or higher is because it exposes a property called [1]EnableUnsecuredResponse in the config. There was a hotfix to add this property in .NET 3.5, but setting it requires creating a custom binding.


    [1] http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.securitybindingelement.enableunsecuredresponse.aspx

    Edited by: dana on Aug 15, 2012 1:30 PM