0

I have a SOAP Header in my application. I need to add a new value of type item with key pcimask and value true to the ClientContext

my clientcontext looks like this when populated:

{EvryCardManagement.ws.card.DCSSCardCreate_V3_0.ClientContextType}
channel: "NBA"
channelField: "NBA"
credentials: "token string"
credentialsField: "string"
customerid: ""
customeridField: ""
ip: "123.456.789.123"
ipField: "123.456.789.123"
item: null
itemField: null
locale: null
localeField: null
orgid: "123456"
orgidField: "123456"
orgunit: "123456"
orgunitField: "123456"
userid: "name"
useridField: "name"

after the I need to add a new element called pcimask with a value true.

UPDATE: in the wsdl there is an element called item (within the ClientContext), and I need to add it to the SOAP Message Headers like this: <item key="pcimask" value="true"/>

In the web-service WSDL the item that I need to set is defined like this:

private itemType[] itemField;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("item", IsNullable=true)]
public itemType[] item {
    get {
        return this.itemField;
        }
    set {
        this.itemField = value;
        }
    }

and so in my code that sets these values I have this:

ClientContextType clientContext = new ClientContextType();

clientContext.userid = edb_service[0].userid;

clientContext.credentials = Common.SOToken;

//clientContext.pc
clientContext.orgid = edb_service[0].orgid;
clientContext.orgunit = edb_service[0].orgunit;
clientContext.customerid = "";
clientContext.channel = edb_service[0].channel;
clientContext.ip = edb_service[0].ip;

and after the ip element I want to set the item:

clientContext.item = edb_service[0].pcimask;

but it won't compile as it's like an array or list, and I need to add a new item so it shows up in the header xml like this:

<item key=”pcimask” value=”true”> 

What do I need to do?

5
  • Do you mean, what do you do after changing the ClientContextType class? Commented Jan 13, 2015 at 18:31
  • @JohnSaunders well, in the wsdl there is an element called item (within the ClientContext), and I need to add it to the SOAP Message Headers like this: <item key="pcimask" value="true"/> and despite reading all over the web about Message Interceptors, and Soap Extensions, I am completely lost. Commented Jan 13, 2015 at 18:39
  • You should not have to add anything. The question should be why isn't this already in the header. Did you try setting the "item" property? Commented Jan 13, 2015 at 18:42
  • I think you're right, I will update with the WSDL definition of the Item which I need to set. Commented Jan 13, 2015 at 18:46
  • @JohnSaunders: I have edited my question to clarify my problem, I think I am meant to add a new member to the item list Commented Jan 13, 2015 at 18:53

1 Answer 1

1

You would have to do something like

clientContext.item = new itemType[]{new itemType{key="pcimask", value="true"}};

item is an array. You have to create an array, populate it with the appropriate data, then use that array to set item. The above is a shortcut for doing that. Step by step:

itemType it = new itemType();
it.key = "pcimask";
it.value = "true";
itemType[] itArray = new itemType[];
itArray[0] = it;
clientContext.item = itArray;

BTW note that this has nothing to do with SOAP headers. Your problem was simply that you don't know how to set an array.

Sign up to request clarification or add additional context in comments.

1 Comment

Thankyou so much, this has taken me a long time and lot's of teeth gnashing to grasp...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.