0

With an Openoffice macro, I want to load data from my local webserver. I tried this code :

Dim stringWeb As String, webAddr As String
Dim doc As Object
Dim opts(0) As New com.sun.star.beans.PropertyValue

webAddr = "http://127.0.0.1:8080"

opts(0).Name = "Hidden"
opts(0).Value = True

doc = StarDesktop.loadComponentFromURL(webAddr, "_blank", 0, opts)
stringWeb = doc.Text.String
doc.close(True)

MsgBox(stringWeb, 0, "Result")

This code works, but how to do when the webserver doesn't listen on port 80 ?? (for example, on port 8080) I tried webAddr = "http://127.0.0.1:8080" but it doesn't work :(

Someone could help me ? Thanks.

Edit: perhaps with this kind of code ?

Dim vParser, vDisp
Dim oUrl As New com.sun.star.util.URL
oUrl.Complete = "http://127.0.0.1:8080"
vParser = createUnoService("com.sun.star.util.URLTransformer")
vParser.parseStrict(oUrl)

vDisp = StarDesktop.queryDispatch(oUrl, "", 0)
If (Not IsNull(vDisp)) Then vDisp.dispatch(oUrl, noargs())

But I don't know how to use it :/

Jerry
  • 1,141
  • 1
  • 13
  • 18
  • Just a random guess, maybe you can drop the `scheme` (`http://`) when giving it an explicit port? Otherwise you'll need to post the error you're getting when you use the second form. – jjm May 13 '16 at 18:25
  • The error is : URL seems to be an unsupported one. – Jerry May 13 '16 at 18:28
  • (Regarding the edit): Good try, but the `URLTransformer` service will not help in this case. I just looked into that. The problem is not actually a URL parsing problem, despite what the error may sound like. – Jim K May 13 '16 at 20:55

2 Answers2

1

This works:

webAddr = "http://178.33.250.62:8080/"  'portquiz.net

On my machine I do not have a web server running at all, so the following results in an IllegalArgumentException ("Unsupported URL"):

webAddr = "http://127.0.0.1"

It seems, then, that the problem is not related to OpenOffice or Basic. Rather, the problem lies in the way your web server is configured.

Jim K
  • 12,824
  • 2
  • 22
  • 51
0

In fact, Apache send a PROPFIND command to the webserver (before GET). And my webserver doesn't know this command.

Headers send :

PROPFIND / HTTP/1.1
Host: 127.0.0.1:8080
User-Agent: Apache OpenOffice/4.1.2
Accept-Encoding: gzip
Depth: 0
Content-Type: application/xml
Content-Length: 259

<?xml version="1.0" encoding="utf-8"?><propfind xmlns="DAV:"><prop><resourcetype xmlnx="DAV:"/><IsReadOnly xmlnx="http://ucb.openoffice.org/dav/props/"/><getcontenttype xmlnx="DAV:"/><supportedlock xmlnx="DAV:"/><lockdiscovery xmlnx="DAV:"/></prop></propfind>
Jerry
  • 1,141
  • 1
  • 13
  • 18