Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] SOAP header in tJavaRow

Hi
I wanted to access the soap headers from a tESBProviderRequest. I have the tESBReq connected to a tJavaRow and then connected to a tXmlMap but it doesnt necessarily have to be like this, I am just looking to extract the header values.
My request envelope looks like this 

<Envelope xmlns="">
    <Header>
        <securityHeader xmlns="">
            <username xmlns=""></username>
            <hased_password xmlns=""></hased_password>
        </securityHeader>
    </Header>
    <Body>
        <getRequest xmlns="">
            <ID xmlns="">100103308911W600</ID>
        </getRequest>
    </Body>
</Envelope>  
How can I retrieve the values of username and password from the header? 
When I print out the input_row it only prints out the body, no headers.
I did try a couple of other threads which suggested "((java.util.Collection<org.apache.cxf.headers.Header>) globalMap.get("tESBProviderRequest_1_HEADERS_SOAP"))" however I cant figure out the way to extract the values.
Appreciate the help.
Thanks
Labels (5)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hello,
I could do it like this :
java.util.Collection<org.apache.cxf.headers.Header> soapHeaders =
((java.util.Collection<org.apache.cxf.headers.Header>) globalMap.get("tESBProviderRequest_1_HEADERS_SOAP"));
java.util.Iterator<org.apache.cxf.headers.Header> it = soapHeaders.iterator();
org.apache.cxf.headers.Header h = (org.apache.cxf.headers.Header) it.next(); 
/*get the key*/
Node n1;
row2.key =  ((Element) h.getName());
/*get the value*/
org.w3c.dom.NodeList nl = ((org.w3c.dom.Element) h.getObject()).getChildNodes();
row2.value = nl.item(0).getTextContent().toString();
/*if you have multiple items*/
org.apache.cxf.headers.Header h = (org.apache.cxf.headers.Header) it.next();
.....

View solution in original post

3 Replies
Elosi_SCR
Contributor II
Contributor II

Any responses? I have the same problem
Anonymous
Not applicable
Author

I ended up just doing this but I would still like to explore a neater refactor of the implementation if possible:
java.util.Collection<org.apache.cxf.headers.Header> soapHeaders = ((java.util.Collection<org.apache.cxf.headers.Header>) globalMap.get("tESBProviderRequest_1_HEADERS_SOAP"));
Iterator<org.apache.cxf.headers.Header> it = soapHeaders.iterator();
org.apache.cxf.headers.Header h = (org.apache.cxf.headers.Header) it.next();
Node n1,n2;
n1 =  ((Element) h.getObject());
NodeList nl = ((Element) h.getObject()).getChildNodes();
var1 = nl.item(1 /* Just trial and error to get this number */ ).getTextContent().trim();   
var2 = nl.item(3 /* same here */ ).getTextContent().trim();  
Anonymous
Not applicable
Author

Hello,
I could do it like this :
java.util.Collection<org.apache.cxf.headers.Header> soapHeaders =
((java.util.Collection<org.apache.cxf.headers.Header>) globalMap.get("tESBProviderRequest_1_HEADERS_SOAP"));
java.util.Iterator<org.apache.cxf.headers.Header> it = soapHeaders.iterator();
org.apache.cxf.headers.Header h = (org.apache.cxf.headers.Header) it.next(); 
/*get the key*/
Node n1;
row2.key =  ((Element) h.getName());
/*get the value*/
org.w3c.dom.NodeList nl = ((org.w3c.dom.Element) h.getObject()).getChildNodes();
row2.value = nl.item(0).getTextContent().toString();
/*if you have multiple items*/
org.apache.cxf.headers.Header h = (org.apache.cxf.headers.Header) it.next();
.....