on 05-25-2016 2:20 AM
Hi All,
I am having trouble using an Xpath expression in Interface Determination. The scenario is File to multiple Idoc but the source file contains an XML wrapped in a Soap Envelope like this:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetDataResponse xmlns="http://www.dummy.com/jdjen9/">
<GetDataResult>
<Elephant>
<elephantName>Jumbo</elephantName>
<elephantDetails>
<foodLimit>0</foodLimit>
</elephantDetails>
<elephantColour>
<colourCode/>
</elephantColour>
<zooAddresses>
<Address>
<addressCode>84475</addressCode>
</Address>
</zooAddresses>
</Elephant>
</GetDataResult>
</GetDataResponse>
</soap:Body>
</soap:Envelope>
The interface is working fully but I would like to control Interface Determination based on a node in the XML. If the node called <Address> exists (shown in red above) then execute a particular operation mapping.
I have tried several Xpath expressions but they don't seem to work. Is it because Xpath does not expect the Soap envelope? If so is there another way to get what I want?
Some of what I have tried:
Any help appreciated.
Che
Hi Che,
After much investigation, the cause why your xpath is not working is because of this namespace:
<GetDataResponse xmlns="http://www.dummy.com/jdjen9/">
This can be removed by using XMLAnonymizerBean
Sample test:
With Address (after Anonymizer transformation)
Without Address (after Anonymizer transformation)
Regards,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mark!
You got it! It looks to be the default behavour of namespace-by-default syntax ("xmlns=").
In this case expression like:
/p1:Envelope/p1:Body/p2:GetDataResponse/p2:GetDataResult/p2:Elephant/p2:zooAddresses/p2:Address EX
should work with setting p2 to "http://www.dummy.com/jdjen9/" in Expression editor.
Regards, Evgeniy.
Hi Evgeniy,
Thanks! I'm afraid it would only work if there is a prefix for "http://www.dummy.com/jdjen9/". Not sure with the latest versions though as I am still on 7.11 SP13.
Regards,
Mark
Hi Mark!
You are absolutely right! PI sometimes treats XPath expressions in a strange manner.
In my XPath expressions testing tool expression:
/soap:Envelope/soap:Body/GetDataResponse/GetDataResult/Elephant/zooAddresses/Address
works so as :
/soap:Envelope/soap:Body/ns1:GetDataResponse/ns1:GetDataResult/ns1:Elephant/ns1:zooAddresses/ns1:Address
with "ns1" set to "http://www.dummy.com/jdjen9/" does.
Regards, Evgeniy.
Hi, Che!
First, you can try to set namespaces for your XPath in condition editor.
If it still doesn't work for you, you should use Mark decision.
You can start with setting prefixes only for Envelope and Body elements.
Just forgot, that you wouldn't be able to see these elements in editor as it's the part of SOAP Envelope.
Just try to set prefixes for all elements of your XPath expression to default namespace which is set in your message
Regards, Evgeniy.
Hi Evgeniy and Mark,
Finally found an xpath expression that works! It makes sense now I think about it. Here is what I now have in the Interface Determination:
Add the following xpath expression:
Add the following two prefixes (both are needed):
With the above in place the node <Address> is successfully located and the correct Operation Mapping is now being called. Looking at one of the screen shots from Mark where he used "/p1:Envelope/p1:Body" gave me the idea to try the above.
Che
Hi All,
First let me say that I am overwhelmed by all your offers of help, what a great community , thank you all.
Okay so it was a late night last night and I need time to go through all the suggestions this morning, but will do so today. I will get back to you with what I find.
Che
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Che!
Try //zooAddresses/Adress EX
Regards, Evgeniy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Che,
In the expression editor, have you added the namespace for the soap prefix?
Regards,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Che,
use the below expression
/GetDataResponse/GetDataResult/Elephant/zooAddresses[Address] EX
or
//zooAddresses[Address] EX
If this does not work, please provide the screenshot of the message type in your outbound interface
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.