Reputation: 1790
I am very confused about the property mediator in the WSO2 Micro intergator suite. There is a field that I need to extract using Xpath and then send to AWS SQS. The following is the document from which I try to extract the field (note that I cropped the bottom half of the document).
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<Waybill
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Waybill-2"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
xmlns:eba="http://ns.tln.nl/eba/schemas/1-0/"
xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:oasis:names:specification:ubl:schema:xsd:Waybill-2 http://docs.oasis-open.org/ubl/prd1-UBL-2.1/xsd/maindoc/UBL-Waybill-2.1.xsd http://ns.tln.nl/eba/schemas/1-0-1/EBA-Extensions.xsd">
<ext:UBLExtensions>
<ext:UBLExtension>
<ext:ExtensionContent>
<eba:ReplyAddress>
<eba:Webservice>
<eba:WebserviceEndPoint>http://www.google.com
</eba:WebserviceEndPoint>
<eba:Username>123</eba:Username>
<eba:Password>123
</eba:Password>
</eba:Webservice>
</eba:ReplyAddress>
</ext:ExtensionContent>
</ext:UBLExtension>
<ext:UBLExtension>
<ext:ExtensionContent>
<eba:ReplyAddress>
<eba:EmailAddress>[email protected]</eba:EmailAddress>
</eba:ReplyAddress>
</ext:ExtensionContent>
</ext:UBLExtension>
</ext:UBLExtensions>
I'm looking to parse the "Waybill" part. No matter what I try with the property, the result is either going to be an error (syntactical) or an empty result.
Examples of non-working code I tried thus far:
<property expression="//s:Body/Waybill" name="wayb" scope="default" type="STRING" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" />
<property expression="$:Body/Waybill" name="messageBody" scope="default" type="STRING" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="urn:oasis:names:specification:ubl:schema:xsd:Waybill-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:eba="http://ns.tln.nl/eba/schemas/1-0/" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:specification:ubl:schema:xsd:Waybill-2 http://docs.oasis-open.org/ubl/prd1-UBL-2.1/xsd/maindoc/UBL-Waybill-2.1.xsd http://ns.tln.nl/eba/schemas/1-0-1/EBA-Extensions.xsd"/>
<property expression="//Waybill" name="messageBody" scope="default" type="STRING" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="urn:oasis:names:specification:ubl:schema:xsd:Waybill-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:eba="http://ns.tln.nl/eba/schemas/1-0/" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:specification:ubl:schema:xsd:Waybill-2 http://docs.oasis-open.org/ubl/prd1-UBL-2.1/xsd/maindoc/UBL-Waybill-2.1.xsd http://ns.tln.nl/eba/schemas/1-0-1/EBA-Extensions.xsd"/>
<property expression="//Waybill" name="messageBody" scope="default" type="STRING" />
Note however that I can easily grab the body field which DOES work:
<property expression="$body" name="messageBody" scope="default" type="STRING"/>
What am I missing here?
Upvotes: 1
Views: 228
Reputation: 24930
The issue here (as is the case with many xml snippets) is the use of namespaces; as the experts will tell you, they are necessary - but, in my opinion, a necessary evil....
One way to deal with them is to disregard them when possible; that, in turn, can be done by using xpath's local-name()
function.
Or, in this case:
//*[local-name()='Waybill']
Upvotes: 1