-
1. Re: Check if header element exists in message Response.
charlyjboss Nov 1, 2010 9:17 AM (in response to charlyjboss)I think this question is not going to be answered, what i need to know is the reason. Is it not well written or do i need to add more details?.
To sum up, i need to know if given a message there is a way to check whether an element exists or not (with namespace included) and add it myself if it isn't included.
Anything would help.
Thanks.
-
2. Re: Check if header element exists in message Response.
tfennelly Nov 9, 2010 9:37 AM (in response to charlyjboss)Hi Carlos... I got your private message... here's the answer...
Sounds like you have 2 issues... handling a large/huge message and conditionally adding a header element.
Handle the huge message by setting th filter type to SAX (default is DOM => can't handle big messages) See User Guide.
For conditionally adding the header... in the versions of Smooks in the ESB (easier in newer versions of Smooks)... easiest way is prob to do something like the following...
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.2.xsd">
<jb:bean beanId="headerDetails" class="java.util.HashMap" createOnElement="order/header">
<jb:value property="secureId" data="order/header/secureId" />
<jb:bean>
<ftl:freemarker applyOnElement="order/header">
<condition>isdef headerDetails.secureId</condition>
<ftl:template><!-- <secureId>blah</secureId> --></ftl:template>
<ftl:use>
<ftl:inline directive="addto" />
</ftl:use>
</ftl:freemarker>
</smooks-resource-list>
So.. capture details about the data in the header into a HasMap and then add a conditional on a template (having an "addto" directive) that's applied to the header fragment.
-
3. Re: Check if header element exists in message Response.
tfennelly Nov 9, 2010 9:39 AM (in response to tfennelly)Oh and... make sure to check the MVEL user docs re the use of "isdef" in the conditional... what I have there might not be 100% right, but it would be something like that.
-
4. Re: Check if header element exists in message Response.
charlyjboss Nov 19, 2010 12:13 PM (in response to tfennelly)Thanks Tom, i'm trying to use your solution, but that code works for an element inside the header right? In my case, the whole header may not be present (<header>...<header>) at all, for example, could be like this:
<Envelope>
<Body>
...
</Body></Envelope>
So, the result message after the transformation is:
<Envelope>
<Body>
...
</Body><Header>
...
</Header>
</Envelope>
Because the "add" directive locates the element at the end of the selector (Envelope in this case)
Is it possible to modify a little bit your solution to make it works for my particular scenario?
Thank you very much.