on 07-10-2014 3:25 PM
Hi, I have a message which must contain XML inside XML, this internal one must start off with the <?xml version="1.0" encoding="utf-8"?> string.
Is there a nice trick for inserting this before an element? (not at the beginning of the mapping, a specific place further inside the XML).
All of the other elements are mapped as part of the message type.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can write a java mapping to add the string anywhere in the xml you need.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah thanks Osman, but then I think it would be like the text inside an element. Which would be fine I think if there were no sub-elements. In this case there are sub-elements so XML rules will not let string data be put in correct?
Data structure is like:
<MySOAPBodyRoot>
<element1></element1>
<element2></element2>
<element3>
[ here is where I want to insert the XML string ]
<subElement1> [ this is like payload root of inside XML ]
<subSubElement></subSubElement>
</subElement1>
</element3>
</MySOAPBodyRoot>
Hmm thinking while I'm typing: What about using any raw data?
Of course your recipient must be able to deal with the encoded data, I suppose
Cheers
Jens
Create a 2nd mapping.
Use the target of 1st mapping as source and
Create new DT with just the record node and use at target.
Do a mapping with the header node of Source to Target with the UDF in between(code below) and select "Return as xml" on source node.
Note: payload is the input for the UDF
int i = payload.indexOf("<subElement1>");
String a = payload.substring(0,i);
String b = payload.substring(i);
String output = a + "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +b;
return output;
Hi Aaron,
correct me if I'm wrong but inserting an additional <?xml... statement within an XML document would render the whole document not-well-formed. While your 3rd party receiver may ignore this I would assume PI does not (easily).
However, never tried this. If Soap Adapter fails I would try with HTTP (depends on your scenario, though).
You got interesting tasks going on there
Cheers
Jens
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.