Reputation: 49
I have a sequence that perform a callout (blocking), because i need to extract some data from the response to create a payload to perform a new callout to another service.
The Callout
<callout action="nextSource" initAxis2ClientOptions="false"
serviceURL="http://192.168.0.33:9764/services/AltaLigeraService?wsdl">
<source type="envelope" />
<target key="myresponse" />
</callout>
So i can log the response:
<property expression="get-property('myresponse')"
name="rta" scope="default" type="STRING" />
<log level="custom">
<property expression="$ctx:rta" name="Respuesta" />
</log>
The response log is:
INFO - LogMediator Respuesta =
<ns:nextSourceResponse xmlns:ns="http://carbon.bbva.gtko.co">
<ns:return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ax2431="http://vo.carbon.bbva.gtko.co/xsd"
xsi:type="ax2431:Automatizacion"> <ax2431:filename1>28189133_AltaLigerao_Oficina_cmarguello_20160408102300_N.txt</ax2431:filename1><ax2431:filename2>28189133_AltaLigerao_Oficina_cmarguello_20160408102300_S.txt</ax2431:filename2>
<ax2431:modulo>ALTA_LIGERA</ax2431:modulo>
</ns:return>
</ns:nextSourceResponse>
So i need to know the values of filename1, filename2 and modulo I try, with xpath, to log filename1 value but i cant do.
<property
expression="fn:concat('filename - ', $ctx:rta/ns:nextSourceResponse/ns:return/ax2431:filename1)"
name="filename1" scope="default" type="STRING" xmlns:ns="http://carbon.bbva.gtko.co" xmlns:ax2431="http://vo.carbon.bbva.gtko.co/xsd"/>
<log level="custom">
<property expression="get-property('filename1')" name="filename"
xmlns:ns="http://carbon.bbva.gtko.co" />
</log>
and the log:
`INFO - LogMediator filename = filename - `
i also try with the same result (same log)
´expression="fn:concat('filename - ', $ctx:rta/ax2431:filename1)"´
`expression="fn:concat('filename - ', $ctx:rta/filename1)"`
Whats the correct way to do that?
Thanks
Upvotes: 0
Views: 87
Reputation: 49
Finally i can. The request:
`<body>
<ns:nextSourceResponse xmlns:ns="http://carbon.bbva.gtko.co">
</ns:nextSourceResponse>
</body>`
The key is in the target:
`<callout action="nextSource" initAxis2ClientOptions="false"
serviceURL="http://192.168.0.33:9764/services/AltaLigeraService?wsdl">
<source type="envelope" />
<target xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]" />
</callout>`
after that i can access value of filename
`<property expression="//ns:nextSourceResponse/ns:return/ax2431:filename1"
name="filename1" scope="default" type="STRING"
xmlns:ax2431="http://vo.carbon.bbva.gtko.co/xsd" xmlns:ns="http://carbon.bbva.gtko.co" />`
Upvotes: 0
Reputation: 2153
Just a test:
<property expression="$body/*"
name="rta" scope="default" type="STRING" />
<log level="custom">
<property expression="$ctx:rta" name="Respuesta" />
</log>
<property expression="//ns:nextSourceResponse/ns:return/ax2431:filename1" name="Respuesta2" xmlns:ns="http://carbon.bbva.gtko.co" xmlns:ax2431="http://vo.carbon.bbva.gtko.co/xsd"/>
<property
expression="fn:concat('test - ', get-property('Respuesta2'))"
name="filename1" scope="default" type="STRING" xmlns:ns="http://carbon.bbva.gtko.co" xmlns:ax2431="http://vo.carbon.bbva.gtko.co/xsd"/>
<log level="custom">
<property expression="get-property('filename1')" name="filename"
xmlns:ns="http://carbon.bbva.gtko.co" />
</log>
The logs:
[2016-04-29 14:19:48,005] INFO - LogMediator Respuesta =
<ns:nextSourceResponse xmlns:ns="http://carbon.bbva.gtko.co"><ns:return xmlns:ax2431="http://vo.carbon.bbva.gtko.co/xsd" xmlns
:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ax2431:Automatizacion"><ax2431:filename1>28189133_AltaLigerao_Oficina_cmarguello_20160408102300_N.txt</ax2431:filename1><ax24
31:filename2>28189133_AltaLigerao_Oficina_cmarguello_20160408102300_S.txt</ax2431:filename2><ax2431:modulo>ALTA_LIGERA</ax2431:modulo></ns:return></ns:nextSourceResponse>
[2016-04-29 14:19:48,007] INFO - LogMediator filename = test - 28189133_AltaLigerao_Oficina_cmarguello_20160408102300_N.txt
If you want to use the $ctx:rta way, please use it like in this property:
<property expression="$ctx:rta//ns:return/ax2431:filename1/text()"
name="Respuesta2" xmlns:ns="http://carbon.bbva.gtko.co" xmlns:ax2431="http://vo.carbon.bbva.gtko.co/xsd"/>
Upvotes: 1