problem accessing data from RESTXQ response

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

problem accessing data from RESTXQ response

Pietro Liuzzo
Dear all,

I am using RESTXQ in my Exist 2.2 to get to a single passages of a text based on the URI provided. Although I don't have yet a lot of text, you could try this for example


which uses the restxq function which I copied below this message to produce the xml response.

When I want to use this to get and display the content so produced with fn:doc-available or fn:doc
 I get this error

err:FODC0005 An error occurred while parsing http://betamasaheft.aai.uni-hamburg.de/api/xml/LIT1367Exodus/1: Server returned HTTP response code: 500

but I do not see where the error in the uri is, it seams to me to follow the rules for xs:anyURI. I also tried to use fn:encode-for-uri to no avail (returns false)

any suggestion on why I get this error?

My aim as said is to use the content of the restxq response.

Thanks a lot!
Pietro  


declare 

    %rest:GET
    %rest:path("/BetMas/api/xml/{$id}/{$level1}")
    %output:method("xml")
function api:get-level1XML($id as xs:string, $level1 as xs:string*){
   (<rest:response>
      <http:response status="200">
        <http:header name="Content-Type" value="application/xml; charset=utf-8"/>
      </http:response>
    </rest:response>,
      let $collection := 'works'
               let $item := api:record($collection, $id)
               return
      if ($item//t:div[parent::t:div[@type='edition']][@n=$level1][t:ab])        
             then 
     <work>
               {
            
                let $recordid := $item/t:TEI/@xml:id
              
                return
                        <data>
                            <id>{data($recordid)}</id>
                            <citation>{($item//t:titleStmt/t:title[@xml:id='t1']/text()|| ' ' || $level1)}</citation>
                            <text>{$item//t:div[parent::t:div[@type='edition']][@n = $level1]//text()}</text>
                           
                            {if (number($level1) > 1)
                            then
                            <previous><a href="http://betamasaheft.aai.uni-hamburg.de/api/xml/{">http://betamasaheft.aai.uni-hamburg.de/api/xml/{$id}/{number($level1) - 1}</previous>
                            else ()
                            }
                           
                              {if (number($level1) = count($item//t:div[parent::t:div[@type='edition']]))
                            then ()
                            else
                            if ($item//t:div[parent::t:div[@type='edition']][@n = (number($level1) + 1)])
                            then
                            <next><a href="http://betamasaheft.aai.uni-hamburg.de/api/xml/{">http://betamasaheft.aai.uni-hamburg.de/api/xml/{$id}/{number($level1) + 1}</next>
                            else ()
                           }
                          
                           <partofwork><a href="http://betamasaheft.aai.uni-hamburg.de/api/xml/{">http://betamasaheft.aai.uni-hamburg.de/api/xml/{$id}</partofwork>
                          
                        </data >
                }
            </work>
            else   
   
            <response>
                <info>No results, sorry</info>
            </response>
     )
};



--
Pietro Maria Liuzzo
cel (DE): +49 (0) 176 61 000 606
Skype: pietro.liuzzo (Quingentole)

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: problem accessing data from RESTXQ response

Joe Wicentowski
Hi Pietro,

Do you see any more detailed logging in exist.log or restxq.log?  

Joe

Sent from my iPad




On Fri, Jan 20, 2017 at 3:30 AM -0500, "Pietro Liuzzo" <[hidden email]> wrote:

Dear all,

I am using RESTXQ in my Exist 2.2 to get to a single passages of a text based on the URI provided. Although I don't have yet a lot of text, you could try this for example


which uses the restxq function which I copied below this message to produce the xml response.

When I want to use this to get and display the content so produced with fn:doc-available or fn:doc
 I get this error

err:FODC0005 An error occurred while parsing http://betamasaheft.aai.uni-hamburg.de/api/xml/LIT1367Exodus/1: Server returned HTTP response code: 500

but I do not see where the error in the uri is, it seams to me to follow the rules for xs:anyURI. I also tried to use fn:encode-for-uri to no avail (returns false)

any suggestion on why I get this error?

My aim as said is to use the content of the restxq response.

Thanks a lot!
Pietro  


declare 

    %rest:GET
    %rest:path("/BetMas/api/xml/{$id}/{$level1}")
    %output:method("xml")
function api:get-level1XML($id as xs:string, $level1 as xs:string*){
   (<rest:response>
      <http:response status="200">
        <http:header name="Content-Type" value="application/xml; charset=utf-8"/>
      </http:response>
    </rest:response>,
      let $collection := 'works'
               let $item := api:record($collection, $id)
               return
      if ($item//t:div[parent::t:div[@type='edition']][@n=$level1][t:ab])        
             then 
     <work>
               {
            
                let $recordid := $item/t:TEI/@xml:id
              
                return
                        <data>
                            <id>{data($recordid)}</id>
                            <citation>{($item//t:titleStmt/t:title[@xml:id='t1']/text()|| ' ' || $level1)}</citation>
                            <text>{$item//t:div[parent::t:div[@type='edition']][@n = $level1]//text()}</text>
                           
                            {if (number($level1) > 1)
                            then
                            <previous><a href="http://betamasaheft.aai.uni-hamburg.de/api/xml/{">http://betamasaheft.aai.uni-hamburg.de/api/xml/{$id}/{number($level1) - 1}</previous>
                            else ()
                            }
                           
                              {if (number($level1) = count($item//t:div[parent::t:div[@type='edition']]))
                            then ()
                            else
                            if ($item//t:div[parent::t:div[@type='edition']][@n = (number($level1) + 1)])
                            then
                            <next><a href="http://betamasaheft.aai.uni-hamburg.de/api/xml/{">http://betamasaheft.aai.uni-hamburg.de/api/xml/{$id}/{number($level1) + 1}</next>
                            else ()
                           }
                          
                           <partofwork><a href="http://betamasaheft.aai.uni-hamburg.de/api/xml/{">http://betamasaheft.aai.uni-hamburg.de/api/xml/{$id}</partofwork>
                          
                        </data >
                }
            </work>
            else   
   
            <response>
                <info>No results, sorry</info>
            </response>
     )
};



--
Pietro Maria Liuzzo
cel (DE): +49 (0) 176 61 000 606
Skype: pietro.liuzzo (Quingentole)

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: problem accessing data from RESTXQ response

Dannes Wessels-3
In reply to this post by Pietro Liuzzo
Hi,


On 20 Jan 2017, at 9:28 , Pietro Liuzzo <[hidden email]> wrote:


I actually did not expect this call to be working; it is an interesting way to check if an XML document can be downloaded from an URL. It is not really an efficient thing to use…. beter to use the HTTP client….

additionally, it is not efficient to use doc(‘http://') to query remote documents. It is not really designed for this usage.

I actually think that the server you connect with, returns a status code 500?

regards

Dannes


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: problem accessing data from RESTXQ response

Pietro Liuzzo
Thanks a lot to all!

yes as said I get 500! I really and sincerely thought doc() was the only way I could actually use the XML returned by this uri... it did work in other situations, although yes (again) with very inefficient results! I will now use the httpclient indeed! or is there anything else which designed for the purpose which I have missed?

The log I have in wrapper.log says the following 

20 Jan 2017 22:29:43,755 [eXistThread-60] WARN  (ServletHandler.java [doHandle]:517) - /exist/apps/BetMas/api/xml/LIT1367Exodus/1
 
java.lang.IllegalArgumentException: Invalid Accept Header Value: 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2' in respect to pattern: '((?:(?:\*\/\*)|(?$
       at org.exquery.http.AcceptHeader.<init>(AcceptHeader.java:78)
       at org.exquery.restxq.impl.RestXqServicesMap.get(RestXqServicesMap.java:170)
       at org.exquery.restxq.impl.RestXqServiceRegistryImpl.findService(RestXqServiceRegistryImpl.java:99)
       at org.exist.extensions.exquery.restxq.impl.RestXqServlet.service(RestXqServlet.java:95)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
       at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
       at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:457)
       at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
       at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:575)
       at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
       at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
       at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
       at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
       at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
       at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
       at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:229)
       at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:103)
       at org.exist.http.urlrewrite.Forward.doRewrite(Forward.java:50)
       at org.exist.http.urlrewrite.XQueryURLRewrite.doRewrite(XQueryURLRewrite.java:567)
       at org.exist.http.urlrewrite.XQueryURLRewrite.service(XQueryURLRewrite.java:355)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
       at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1448)
       at de.betterform.agent.web.filter.XFormsFilter.doFilter(XFormsFilter.java:164)
       at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)
       at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
       at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
       at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:533)
       at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
       at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
       at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
       at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
       at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
       at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
       at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
       at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
       at org.eclipse.jetty.server.Server.handle(Server.java:368)
       at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:488)
       at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:932)
       at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:994)
       at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640)
       at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
       at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
       at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
       at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
       at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
       at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
       at java.lang.Thread.run(Thread.java:745)


2017-01-20 20:31 GMT+01:00 Dannes Wessels <[hidden email]>:
Hi,


On 20 Jan 2017, at 9:28 , Pietro Liuzzo <[hidden email]> wrote:


I actually did not expect this call to be working; it is an interesting way to check if an XML document can be downloaded from an URL. It is not really an efficient thing to use…. beter to use the HTTP client….

additionally, it is not efficient to use doc(‘http://') to query remote documents. It is not really designed for this usage.

I actually think that the server you connect with, returns a status code 500?

regards

Dannes




--
Pietro Maria Liuzzo
cel (DE): +49 (0) 176 61 000 606
Skype: pietro.liuzzo (Quingentole)

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: problem accessing data from RESTXQ response

Adam Retter
I may be mistaken but I think the error you are getting is correct, i.e.

java.lang.IllegalArgumentException: Invalid Accept Header Value:
'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2'

If I look at the RFC for the HTTP Accept Header
(https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html) then it has
the following BNF:

Accept         = "Accept" ":"
                        #( media-range [ accept-params ] )

media-range    = ( "*/*"
                        | ( type "/" "*" )
                        | ( type "/" subtype )
                        ) *( ";" parameter )
accept-params  = ";" "q" "=" qvalue *( accept-extension )
accept-extension = ";" token [ "=" ( token | quoted-string ) ]

In your Accept Header after the "image/jpeg" you have a media-range
which is just "*", as far as I can see that is not valid according to
the HTTP specification.

So what is generating your accept header?

Thanks Adam.

On 21 January 2017 at 06:44, Pietro Liuzzo <[hidden email]> wrote:

> Thanks a lot to all!
>
> yes as said I get 500! I really and sincerely thought doc() was the only way
> I could actually use the XML returned by this uri... it did work in other
> situations, although yes (again) with very inefficient results! I will now
> use the httpclient indeed! or is there anything else which designed for the
> purpose which I have missed?
>
> The log I have in wrapper.log says the following
>
> 20 Jan 2017 22:29:43,755 [eXistThread-60] WARN  (ServletHandler.java
> [doHandle]:517) - /exist/apps/BetMas/api/xml/LIT1367Exodus/1
>  java.lang.IllegalArgumentException: Invalid Accept Header Value:
> 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2' in respect to
> pattern: '((?:(?:\*\/\*)|(?$
>        at org.exquery.http.AcceptHeader.<init>(AcceptHeader.java:78)
>        at
> org.exquery.restxq.impl.RestXqServicesMap.get(RestXqServicesMap.java:170)
>        at
> org.exquery.restxq.impl.RestXqServiceRegistryImpl.findService(RestXqServiceRegistryImpl.java:99)
>        at
> org.exist.extensions.exquery.restxq.impl.RestXqServlet.service(RestXqServlet.java:95)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
>        at
> org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
>        at
> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:457)
>        at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
>        at
> org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:575)
>        at
> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
>        at
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
>        at
> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
>        at
> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
>        at
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
>        at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
>        at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:229)
>        at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:103)
>        at org.exist.http.urlrewrite.Forward.doRewrite(Forward.java:50)
>        at
> org.exist.http.urlrewrite.XQueryURLRewrite.doRewrite(XQueryURLRewrite.java:567)
>        at
> org.exist.http.urlrewrite.XQueryURLRewrite.service(XQueryURLRewrite.java:355)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
>        at
> org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
>        at
> org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1448)
>        at
> de.betterform.agent.web.filter.XFormsFilter.doFilter(XFormsFilter.java:164)
>        at
> org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)
>        at
> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
>        at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
>        at
> org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:533)
>        at
> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
>        at
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
>        at
> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
>        at
> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
>        at
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
>        at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
>        at
> org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
>        at
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
>        at org.eclipse.jetty.server.Server.handle(Server.java:368)
>        at
> org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:488)
>        at
> org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:932)
>        at
> org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:994)
>        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640)
>        at
> org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
>        at
> org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
>        at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
>        at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
>        at
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
>        at
> org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
>        at java.lang.Thread.run(Thread.java:745)
>
>
> 2017-01-20 20:31 GMT+01:00 Dannes Wessels <[hidden email]>:
>>
>> Hi,
>>
>>
>> On 20 Jan 2017, at 9:28 , Pietro Liuzzo <[hidden email]> wrote:
>>
>>
>> doc-available("http://betamasaheft.aai.uni-hamburg.de/api/xml/LIT1367Exodus/1”)
>>
>>
>> I actually did not expect this call to be working; it is an interesting
>> way to check if an XML document can be downloaded from an URL. It is not
>> really an efficient thing to use…. beter to use the HTTP client….
>>
>> additionally, it is not efficient to use doc(‘http://') to query remote
>> documents. It is not really designed for this usage.
>>
>> I actually think that the server you connect with, returns a status code
>> 500?
>>
>> regards
>>
>> Dannes
>>
>
>
>
> --
> Pietro Maria Liuzzo
> cel (DE): +49 (0) 176 61 000 606
> Skype: pietro.liuzzo (Quingentole)
> https://uk.linkedin.com/in/pietroliuzzo
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Exist-open mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/exist-open
>



--
Adam Retter

eXist Developer
{ United Kingdom }
[hidden email]
irc://irc.freenode.net/existdb

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: problem accessing data from RESTXQ response

Pietro Liuzzo
Dear all, 

thanks a lot for your replies, my problem is now sorted using the httpclient package as suggested. Indeed this suggestion is helping me for many other improvements.

I did not do anything to set such Accept Header as far as I know.  All I did was writing the restxq function which I posted... could this be set by nginx in the wrong way somehow?

thanks a lot

Pietro

2017-01-21 8:11 GMT+01:00 Adam Retter <[hidden email]>:
I may be mistaken but I think the error you are getting is correct, i.e.

java.lang.IllegalArgumentException: Invalid Accept Header Value:
'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2'

If I look at the RFC for the HTTP Accept Header
(https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html) then it has
the following BNF:

Accept         = "Accept" ":"
                        #( media-range [ accept-params ] )

media-range    = ( "*/*"
                        | ( type "/" "*" )
                        | ( type "/" subtype )
                        ) *( ";" parameter )
accept-params  = ";" "q" "=" qvalue *( accept-extension )
accept-extension = ";" token [ "=" ( token | quoted-string ) ]

In your Accept Header after the "image/jpeg" you have a media-range
which is just "*", as far as I can see that is not valid according to
the HTTP specification.

So what is generating your accept header?

Thanks Adam.

On 21 January 2017 at 06:44, Pietro Liuzzo <[hidden email]> wrote:
> Thanks a lot to all!
>
> yes as said I get 500! I really and sincerely thought doc() was the only way
> I could actually use the XML returned by this uri... it did work in other
> situations, although yes (again) with very inefficient results! I will now
> use the httpclient indeed! or is there anything else which designed for the
> purpose which I have missed?
>
> The log I have in wrapper.log says the following
>
> 20 Jan 2017 22:29:43,755 [eXistThread-60] WARN  (ServletHandler.java
> [doHandle]:517) - /exist/apps/BetMas/api/xml/LIT1367Exodus/1
>  java.lang.IllegalArgumentException: Invalid Accept Header Value:
> 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2' in respect to
> pattern: '((?:(?:\*\/\*)|(?$
>        at org.exquery.http.AcceptHeader.<init>(AcceptHeader.java:78)
>        at
> org.exquery.restxq.impl.RestXqServicesMap.get(RestXqServicesMap.java:170)
>        at
> org.exquery.restxq.impl.RestXqServiceRegistryImpl.findService(RestXqServiceRegistryImpl.java:99)
>        at
> org.exist.extensions.exquery.restxq.impl.RestXqServlet.service(RestXqServlet.java:95)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
>        at
> org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
>        at
> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:457)
>        at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
>        at
> org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:575)
>        at
> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
>        at
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
>        at
> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
>        at
> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
>        at
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
>        at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
>        at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:229)
>        at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:103)
>        at org.exist.http.urlrewrite.Forward.doRewrite(Forward.java:50)
>        at
> org.exist.http.urlrewrite.XQueryURLRewrite.doRewrite(XQueryURLRewrite.java:567)
>        at
> org.exist.http.urlrewrite.XQueryURLRewrite.service(XQueryURLRewrite.java:355)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
>        at
> org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
>        at
> org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1448)
>        at
> de.betterform.agent.web.filter.XFormsFilter.doFilter(XFormsFilter.java:164)
>        at
> org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)
>        at
> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
>        at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
>        at
> org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:533)
>        at
> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
>        at
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
>        at
> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
>        at
> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
>        at
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
>        at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
>        at
> org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
>        at
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
>        at org.eclipse.jetty.server.Server.handle(Server.java:368)
>        at
> org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:488)
>        at
> org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:932)
>        at
> org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:994)
>        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640)
>        at
> org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
>        at
> org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
>        at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
>        at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
>        at
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
>        at
> org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
>        at java.lang.Thread.run(Thread.java:745)
>
>
> 2017-01-20 20:31 GMT+01:00 Dannes Wessels <[hidden email]>:
>>
>> Hi,
>>
>>
>> On 20 Jan 2017, at 9:28 , Pietro Liuzzo <[hidden email]> wrote:
>>
>>
>> doc-available("http://betamasaheft.aai.uni-hamburg.de/api/xml/LIT1367Exodus/1”)
>>
>>
>> I actually did not expect this call to be working; it is an interesting
>> way to check if an XML document can be downloaded from an URL. It is not
>> really an efficient thing to use…. beter to use the HTTP client….
>>
>> additionally, it is not efficient to use doc(‘http://') to query remote
>> documents. It is not really designed for this usage.
>>
>> I actually think that the server you connect with, returns a status code
>> 500?
>>
>> regards
>>
>> Dannes
>>
>
>
>
> --
> Pietro Maria Liuzzo
> cel (DE): <a href="tel:%2B49%20%280%29%20176%2061%20000%20606" value="+4917661000606">+49 (0) 176 61 000 606
> Skype: pietro.liuzzo (Quingentole)
> https://uk.linkedin.com/in/pietroliuzzo
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Exist-open mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/exist-open
>



--
Adam Retter

eXist Developer
{ United Kingdom }
[hidden email]
irc://irc.freenode.net/existdb



--
Pietro Maria Liuzzo
cel (DE): +49 (0) 176 61 000 606
Skype: pietro.liuzzo (Quingentole)

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: problem accessing data from RESTXQ response

Adam Retter
The accept header will be sent from the client that you are using to make the request to RESTXQ

On 26 Jan 2017 5:49 p.m., "Pietro Liuzzo" <[hidden email]> wrote:
Dear all, 

thanks a lot for your replies, my problem is now sorted using the httpclient package as suggested. Indeed this suggestion is helping me for many other improvements.

I did not do anything to set such Accept Header as far as I know.  All I did was writing the restxq function which I posted... could this be set by nginx in the wrong way somehow?

thanks a lot

Pietro

2017-01-21 8:11 GMT+01:00 Adam Retter <[hidden email]>:
I may be mistaken but I think the error you are getting is correct, i.e.

java.lang.IllegalArgumentException: Invalid Accept Header Value:
'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2'

If I look at the RFC for the HTTP Accept Header
(https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html) then it has
the following BNF:

Accept         = "Accept" ":"
                        #( media-range [ accept-params ] )

media-range    = ( "*/*"
                        | ( type "/" "*" )
                        | ( type "/" subtype )
                        ) *( ";" parameter )
accept-params  = ";" "q" "=" qvalue *( accept-extension )
accept-extension = ";" token [ "=" ( token | quoted-string ) ]

In your Accept Header after the "image/jpeg" you have a media-range
which is just "*", as far as I can see that is not valid according to
the HTTP specification.

So what is generating your accept header?

Thanks Adam.

On 21 January 2017 at 06:44, Pietro Liuzzo <[hidden email]> wrote:
> Thanks a lot to all!
>
> yes as said I get 500! I really and sincerely thought doc() was the only way
> I could actually use the XML returned by this uri... it did work in other
> situations, although yes (again) with very inefficient results! I will now
> use the httpclient indeed! or is there anything else which designed for the
> purpose which I have missed?
>
> The log I have in wrapper.log says the following
>
> 20 Jan 2017 22:29:43,755 [eXistThread-60] WARN  (ServletHandler.java
> [doHandle]:517) - /exist/apps/BetMas/api/xml/LIT1367Exodus/1
>  java.lang.IllegalArgumentException: Invalid Accept Header Value:
> 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2' in respect to
> pattern: '((?:(?:\*\/\*)|(?$
>        at org.exquery.http.AcceptHeader.<init>(AcceptHeader.java:78)
>        at
> org.exquery.restxq.impl.RestXqServicesMap.get(RestXqServicesMap.java:170)
>        at
> org.exquery.restxq.impl.RestXqServiceRegistryImpl.findService(RestXqServiceRegistryImpl.java:99)
>        at
> org.exist.extensions.exquery.restxq.impl.RestXqServlet.service(RestXqServlet.java:95)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
>        at
> org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
>        at
> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:457)
>        at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
>        at
> org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:575)
>        at
> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
>        at
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
>        at
> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
>        at
> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
>        at
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
>        at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
>        at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:229)
>        at org.eclipse.jetty.server.Dispatcher.forward(Dispatcher.java:103)
>        at org.exist.http.urlrewrite.Forward.doRewrite(Forward.java:50)
>        at
> org.exist.http.urlrewrite.XQueryURLRewrite.doRewrite(XQueryURLRewrite.java:567)
>        at
> org.exist.http.urlrewrite.XQueryURLRewrite.service(XQueryURLRewrite.java:355)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
>        at
> org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
>        at
> org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1448)
>        at
> de.betterform.agent.web.filter.XFormsFilter.doFilter(XFormsFilter.java:164)
>        at
> org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)
>        at
> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
>        at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
>        at
> org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:533)
>        at
> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
>        at
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
>        at
> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
>        at
> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
>        at
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
>        at
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
>        at
> org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
>        at
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
>        at org.eclipse.jetty.server.Server.handle(Server.java:368)
>        at
> org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:488)
>        at
> org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:932)
>        at
> org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:994)
>        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640)
>        at
> org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
>        at
> org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
>        at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
>        at
> org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
>        at
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
>        at
> org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
>        at java.lang.Thread.run(Thread.java:745)
>
>
> 2017-01-20 20:31 GMT+01:00 Dannes Wessels <[hidden email]>:
>>
>> Hi,
>>
>>
>> On 20 Jan 2017, at 9:28 , Pietro Liuzzo <[hidden email]> wrote:
>>
>>
>> doc-available("http://betamasaheft.aai.uni-hamburg.de/api/xml/LIT1367Exodus/1”)
>>
>>
>> I actually did not expect this call to be working; it is an interesting
>> way to check if an XML document can be downloaded from an URL. It is not
>> really an efficient thing to use…. beter to use the HTTP client….
>>
>> additionally, it is not efficient to use doc(‘http://') to query remote
>> documents. It is not really designed for this usage.
>>
>> I actually think that the server you connect with, returns a status code
>> 500?
>>
>> regards
>>
>> Dannes
>>
>
>
>
> --
> Pietro Maria Liuzzo
> cel (DE): <a href="tel:%2B49%20%280%29%20176%2061%20000%20606" value="+4917661000606" target="_blank">+49 (0) 176 61 000 606
> Skype: pietro.liuzzo (Quingentole)
> https://uk.linkedin.com/in/pietroliuzzo
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Exist-open mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/exist-open
>



--
Adam Retter

eXist Developer
{ United Kingdom }
[hidden email]
irc://irc.freenode.net/existdb



--
Pietro Maria Liuzzo
cel (DE): +49 (0) 176 61 000 606
Skype: pietro.liuzzo (Quingentole)

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Loading...