Dear BasexTalk,
for different (good or bad) reasons, I would like to use the java HTTPConnection instead of the http:client module. But, I am not able to find the correct syntax for these statements. I have tried the middle dot character to force the correct type, without success I receive always the message : [XPTY0004] java.net.URL instance expected as first argument, xs:anyURI found.
Any idea? Thank you in advance
declare namespace HttpURLConnection ="java.net.HttpURLConnection"; declare namespace URL ="java.net.URL";
let $urlString := "https:www.google.com" let $url := URL:new($urlString) let $httpConn := URL:openConnection($url)
return $urlString
Hi André,
Some Java types are automatically converted to XQuery types [1]. It’s currently not possible to suppress the conversion.
If your code contains more than one, two Java calls, it’s usually cleaner to write some Java and XQuery wrapper code. For better packaging, the files can be embedded in a “combined module” [2].
Hope this helps, Christian
[1] https://docs.basex.org/wiki/Java_Bindings#Data_Types [2] https://docs.basex.org/wiki/Repository#Combined
On Mon, Dec 14, 2020 at 8:44 AM Andre Bovy andre.bovy@gmail.com wrote:
Dear BasexTalk,
for different (good or bad) reasons, I would like to use the java HTTPConnection instead of the http:client module. But, I am not able to find the correct syntax for these statements. I have tried the middle dot character to force the correct type, without success I receive always the message : [XPTY0004] java.net.URL instance expected as first argument, xs:anyURI found.
Any idea? Thank you in advance
declare namespace HttpURLConnection ="java.net.HttpURLConnection"; declare namespace URL ="java.net.URL";
let $urlString := "https:www.google.com" let $url := URL:new($urlString) let $httpConn := URL:openConnection($url)
return $urlString
basex-talk@mailman.uni-konstanz.de