Use of WEBSERVICE within a macro in LibreOffice 6.0.1.1

Hi,

Since the last update (security update on the WEBSERVICE function), I cannot use it within a macro like I used to.

The following macro was working nicely prior to the update and I get now an “Illegal Argument” exception. If I try manually to call WEBSERVICE with the built URL, it works…

Any hint?

Sub CallWS
 
dim currentCell
dim currentRow
dim currentSheet

currentSheet = ThisComponent.getCurrentController().getActiveSheet()
currentCell = ThisComponent.getCurrentSelection()
currentRow = currentCell.CellAddress.Row()

dim RowDate as string
dim RowCredit as string
dim RowDebit as string
dim RowNature as string

RowDate = currentSheet.getCellByPosition(0,currentRow).getString()
RowNature = currentSheet.getCellByPosition(1,currentRow).getString()
RowDebit = currentSheet.getCellByPosition(4,currentRow).getValue()
RowCredit = currentSheet.getCellByPosition(5,currentRow).getValue()

svc = createUnoService("com.sun.star.sheet.FunctionAccess")
dim ss as string
ss = "https://#hostname#/?date="+RowDate+"&credit="+RowCredit+"&debit="+RowDebit+"&nature="+RowNature
A = svc.callFunction("WEBSERVICE",Array(ss))

currentSheet.getCellByPosition(2,currentRow).setString(A)

End Sub

In case this helps:

Version: 6.0.1.1
Build ID: 1:6.0.1-1
Threads CPU : 4; OS : Linux 4.9; UI Render : par défaut; VCL: gtk2; 
Locale : fr-FR (fr_FR.utf8); Calc: group

Hello @albatros,

Just looking at your code i saw that RowDebit and RowCredit are defined as Strings, yet a Double value is being assigned to them by getValue().

Try getString() on them too, or else define them as Double, to see if that solves the problem already.

Thanks @librebel for the help.

If I do that (changing for double), I got an error when doing the concatenation. If I change for getString, I end up with the monetary symbol (which I don’t want).

Leaving them as string and using getValue doesn’t seem to bother it too much: I can see the variable contains the value as a string and I can do the concatenation without any issue.

Hello,

Cannot speak of your macro, but there does seem to be a problem with WEBSERVICE.

There was a bug report (#104989) filed & fixed a while back. Using this code from the bug report:

Sub Main
svc = createUnoService( "com.sun.star.sheet.FunctionAccess" ) 'Create a service to use Calc functions
XML_String = svc.callFunction("WEBSERVICE",array("http://www.lipsum.com/feed/xml?amount=2&what=paras&start=Yes"))
Lipsum = svc.callFunction("FILTERXML", array(XML_String, "/feed/lipsum" ))
Print Lipsum
End Sub

Does work in LO v5.4.3.2 but causes an error in v5.4.5.1 and this dev version:

    Version: 6.0.1.0.0+
Build ID: d51c01846afb9bea5a39fd48fbb30b9fd02c2870
CPU threads: 4; OS: Linux 4.13; UI render: default; VCL: gtk2; 
TinderBox: Linux-rpm_deb-x86_64@70-TDF, Branch:libreoffice-6-0, Time: 2018-02-08_10:01:18
Locale: en-US (en_US.UTF-8); Calc: group

with the error being:

BASIC runtime error.
An exception occurred 
Type: com.sun.star.lang.IllegalArgumentException
Message: .

pointing to line:

 XML_String = svc.callFunction("WEBSERVICE",array("http://www.lipsum.com/feed/xml?amount=2&what=paras&start=Yes"))

So it appears to be a recent problem and should be reported as a bug (file here).

Feel free to refer to this post with a link.

@Ratslinger, thank you to pointing to this bug.

The symptoms seem exactly the same as the ones I’m facing since the update. I have opened a new bug, pointing to here.