Author Message
DmitryPesotsky
Joined: Nov 18, 2013
Messages: 30
Offline
Hi colleagues!
I'm using default rest web services connector in OD 7.0 application.
Is it possible to parse the response using default rest editor?
I mean using Output parameters assign to the OD variables values from the response (not to use ALL return parameter).

Get this response from the web service:
<u:UBS_TRANSFER xmlns:u="http://www.unisab.ru/ubs/system/base">
<u:P n="?????? ??????????" r="9">
<u:S n="SID" v="R_GL_EX_AVAYA_1" />
<u:S n="UID" v="{31CFACA4-99E1-4D88-875F-67FA19213AB0}" />
<u:S n="UID ???????" v="{S438EPPOM-2016069160257-4}" />
<u:S n="???????????" v="UBS" />
<u:DT n="???? ????????" v="2016-03-09T19:03:31.637" />
<u:I2 n="??? ????????" v="0" />
<u:S n="????? ??????" v="" />
<u:P n="???? ??????" r="23">
<u:S n="CustomerAccountNumber" v="40702810100100002927" />
<u:M n="TotalCash" v="24891245" />
<u:I4 n="TotalTransfer" v="1" />
<u:S n="NumberTransfer1" v="88" />
<u:M n="CashTransfer1" v="1.99" />
<u:S n="TrunsferAccountNumber1" v="40101810800000010041" />
<u:I4 n="TransferId1" v="24891245" />
<u:S n="NumberTransfer2" v="" />
<u:M n="CashTransfer2" v="0" />
<u:S n="TrunsferAccountNumber2" v="" />
<u:I4 n="TransferId2" v="0" />
<u:S n="NumberTransfer3" v="" />
<u:M n="CashTransfer3" v="0" />
<u:S n="TrunsferAccountNumber3" v="" />
<u:I4 n="TransferId3" v="0" />
<u:S n="NumberTransfer4" v="" />
<u:M n="CashTransfer4" v="0" />
<u:S n="TrunsferAccountNumber4" v="" />
<u:I4 n="TransferId4" v="0" />
<u:S n="NumberTransfer5" v="" />
<u:M n="CashTransfer5" v="0" />
<u:S n="TrunsferAccountNumber5" v="" />
<u:I4 n="TransferId5" v="0" />
</u:P>
<u:S n="Branch" v="33" />
</u:P>
</u:UBS_TRANSFER>

Thanks in advance!
RossYakulis
Joined: Nov 6, 2013
Messages: 2652
Offline
You can use an "xpath" like syntax to specify fields. See attachment.
  • [Thumb - Capture.PNG]
[Disk] Download
RossYakulis
Joined: Nov 6, 2013
Messages: 2652
Offline
I created a bug report to fix the documentation.
DmitryPesotsky
Joined: Nov 18, 2013
Messages: 30
Offline
Thanks a lot, Ross!

Is it possible to get attribute values using xpath?
It seems like xpath 'engine' from REST connector is able to return only value from tags, like 'Hello':
<tag>Hello</tag>
But not from attributes, like 'Hello':
<tag att="Hello" />
RossYakulis
Joined: Nov 6, 2013
Messages: 2652
Offline
did you try /node[@attribute] ?
DmitryPesotsky
Joined: Nov 18, 2013
Messages: 30
Offline
/u:UBS_TRANSFER/u:P/u:P/u:M/[@v]
result: (empty)
Web Service Request -> http://s600bizznew/BTSHTTP/BTSHTTPReceive.dll?FSBRouter
EXCEPTION: javax.xml.transform.TransformerException: A location step was expected following the '/' or '//' token.
Capturing exception [javax.xml.xpath.XPathExpressionException]. Message [javax.xml.transform.TransformerException: A location step was expected following the '/' or '//' token.]
session id:S438EPPOM-2016070152111-19 | minbank01:GetData | Catch error trying get info from ABS #1 web services | WS:Answer2 :

number(/u:UBS_TRANSFER/u:P/u:P/u:M/[@v])
result: (empty)
Web Service Request -> http://s600bizznew/BTSHTTP/BTSHTTPReceive.dll?FSBRouter
EXCEPTION: javax.xml.transform.TransformerException: A location step was expected following the '/' or '//' token.
Capturing exception [javax.xml.xpath.XPathExpressionException]. Message [javax.xml.transform.TransformerException: A location step was expected following the '/' or '//' token.]
session id:S438EPPOM-2016070152331-20 | minbank01:GetData | Catch error trying get info from ABS #1 web services | WS:Answer2 :


I'm using this resource for xpath testing:
http://www.freeformatter.com/xpath-tester.html#ad-output
And including attribute in [ ] doesn't work there.
But other requests work fine, like:
number(/u:UBS_TRANSFER/u:P/u:P/u:M/@v)
/u:UBS_TRANSFER/u:P/u:P/u:M/@v
//u:M[2]/@v
But they don't work in OD, unfortunately.

In number case instead of emptiness I get 'NaN'.
RossYakulis
Joined: Nov 6, 2013
Messages: 2652
Offline
The code uses javax.xml.xpath to parse the result.
DmitryPesotsky
Joined: Nov 18, 2013
Messages: 30
Offline
Hi Ross.

We've decided to test xpath function from REST connector and javax.xml.xpath.
We've made test application. It uses REST connector to request data from open web service:
http://www.thomas-bayer.com/sqlrest/
It stores xml (ALL) data to OD variable 'ans'.

In REST connector we also use xpath to get attribute value to variable 'ans01':
//ITEMList/@href

Then we have Servlet container where we use javax.xml.xpath to get the same attribute value from xml in variable 'ans' using the same xpath:
//ITEMList/@href

Results are different:
xpath from REST connector returns nothing
xpath from javax.xml.xpath returns attribute value: http://www.thomas-bayer.com/sqlrest/ITEM/

Where the problem could be?
It looks like xpath from REST connector uses something more than javax.xml.xpath, some kind of additional handling which prevents getting the result.

SCREENS:
image
image

REPORT:
11/03/2016 15:16:39:608 INFO - In Progress | session id:pom-1-2016071121639-9 | xpath01:untitledData1 | | | ans1 | | 00001138391457698588
11/03/2016 15:16:39:609 INFO - In Progress | session id:pom-1-2016071121639-9 | xpath01:untitledData1 | | | ans | <resource xmlns:xlink="http://www.w3.org/1999/xlink">
<CUSTOMERList xlink:href="http://www.thomas-bayer.com/sqlrest/CUSTOMER/">CUSTOMER</CUSTOMERList>
<INVOICEList xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/">INVOICE</INVOICEList>
<ITEMList xlink:href="http://www.thomas-bayer.com/sqlrest/ITEM/">ITEM</ITEMList>
<PRODUCTList xlink:href="http://www.thomas-bayer.com/sqlrest/PRODUCT/">PRODUCT</PRODUCTList>
</resource> | 00001138391457698588
11/03/2016 15:16:39:661 INFO - In Progress | session id:pom-1-2016071121639-9 | xpath01:untitledData2 | | | xpath01 | http://www.thomas-bayer.com/sqlrest/ITEM/ | 00001138391457698588

TRACE:
11/03/2016 15:16:38:990 INFO - 1B055A7B3C785A82698B5B4226D1CECB:/xpath01 : Starting REST web service operation [untitled]
11/03/2016 15:16:39:094 DEBUG - 1B055A7B3C785A82698B5B4226D1CECB:/xpath01 : Web Service Request -> http://www.thomas-bayer.com/sqlrest/
11/03/2016 15:16:39:492 DEBUG - 1B055A7B3C785A82698B5B4226D1CECB:/xpath01 : Storing [<resource xmlns:xlink="http://www.w3.org/1999/xlink">
<CUSTOMERList xlink:href="http://www.thomas-bayer.com/sqlrest/CUSTOMER/">CUSTOMER</CUSTOMERList>
<INVOICEList xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/">INVOICE</INVOICEList>
<ITEMList xlink:href="http://www.thomas-bayer.com/sqlrest/ITEM/">ITEM</ITEMList>
<PRODUCTList xlink:href="http://www.thomas-bayer.com/sqlrest/PRODUCT/">PRODUCT</PRODUCTList>
</resource>] to: ans
11/03/2016 15:16:39:605 DEBUG - 1B055A7B3C785A82698B5B4226D1CECB:/xpath01 : Storing [] to: ans1
11/03/2016 15:16:39:606 DEBUG - 1B055A7B3C785A82698B5B4226D1CECB:/xpath01 : Web Service Reply <- <resource xmlns:xlink="http://www.w3.org/1999/xlink">
<CUSTOMERList xlink:href="http://www.thomas-bayer.com/sqlrest/CUSTOMER/">CUSTOMER</CUSTOMERList>
<INVOICEList xlink:href="http://www.thomas-bayer.com/sqlrest/INVOICE/">INVOICE</INVOICEList>
<ITEMList xlink:href="http://www.thomas-bayer.com/sqlrest/ITEM/">ITEM</ITEMList>
<PRODUCTList xlink:href="http://www.thomas-bayer.com/sqlrest/PRODUCT/">PRODUCT</PRODUCTList>
</resource>
RossYakulis
Joined: Nov 6, 2013
Messages: 2652
Offline
For some reason when the the setNamespaceAware is commented out things work fine.


DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
//domFactory.setNamespaceAware(true);
DocumentBuilder builder = domFactory.newDocumentBuilder();
Document doc = builder.parse(new ByteArrayInputStream(out.toByteArray()));



What exact version of OD are you on? I can provide you with a patch.
DmitryPesotsky
Joined: Nov 18, 2013
Messages: 30
Offline
It's OD 7.0.1.0804
Thanks in advance!
RossYakulis
Joined: Nov 6, 2013
Messages: 2652
Offline
In your eclipse plugins directory (path similar to below, adjust for your setup)

C:\SageReleases\SageRel-7.0.1\eclipse\plugins\com.avaya.sce.restws.ui_7.0.0.1801\lib


replace the avrest-rt.jar with the attached and restart eclipse. In your application WEB-INF/lib you shoudl see avrest-rt.07.01.08.04.p1.jar
Filename avrest-rt.jar [Disk] Download
DmitryPesotsky
Joined: Nov 18, 2013
Messages: 30
Offline
Thanks a lot, Ross, it works!

What is the fade of this case?
Will that .jar be included in next OD release or should we remember installing it further?
RossYakulis
Joined: Nov 6, 2013
Messages: 2652
Offline
This fix will be in the 7.1 release out in May. fortunately you found this now as the GA build for May will be soon.
DmitryPesotsky
Joined: Nov 18, 2013
Messages: 30
Offline
That's a good news! :D
Thanks a lot, Ross!
Go to:   
Mobile view