REST service problems - 401-Header sent‏

Monday, 2 July 2012 · 2 messages · last reply 3 Jul 2012
ME
MyNew EMail2 Jul 2012 23:49 #
Hi again,
Quoted text · 3 lines
> What do you exactly mean with "long XQuery request"? Could you provide > us with an example that demonstrates the problem (I didn't manage to > track it down locally)?I'm using PHP with cURL to call the REST service (with standard username and password [admin, admin] for testing). Furthermore I'm using the BaseX HTTP Server (basexhttp.bat).Here is some code summary (first example works well):
<?php//...	$query      = 'let $x := <abc>
	                           <aaa>Test</aaa>
				   <aaa>Test</aaa>
				   <aaa>Test</aaa>
				   <aaa>Test</aaa>
				   <aaa>Test</aaa>
				   <aaa>Test</aaa>
				   <aaa>Test</aaa>
				   <bb test="123"><a>test</a></bb>
				   <bb test="123"><a>test</a></bb>
				   <bb test="123"><a>test</a></bb>
				</abc>
	               return insert node $x as last into //test';
	$fullQuery  = '<query xmlns="http://basex.org/rest">';
    $fullQuery .= '<text><![CDATA[ '.$query.']]></text>';
    $fullQuery .= '</query>';//...//set authorization stuff//set Content-Type header to application/xml and send a POST request to http://localhost:8984/rest/MyDb/test.xml with $fullQuery in body.//This works. Example XML will be inserted.?>
But if the XML part (let $x := ...) or the XQuery part is longer I get this response
(and I'm authorized the same way as in the first example):
HTTP/1.1 401 Unauthorized
WWW-Authenticate: BasicContent-Length: 31 Server: Jetty(6.1.26)
This example does'nt work:<?php	$query      = 'let $x := <abc>
	                           <aaa>Test</aaa>
							   <aaa>Test</aaa>
							   <aaa>Test</aaa>
							   <aaa>Test</aaa>
							   <aaa>Test</aaa>
							   <aaa>Test</aaa>
							   <aaa>Test</aaa>
							   <aaa>Test</aaa>
							   <aaa>Test</aaa>
							   <aaa>Test</aaa>
							   <aaa>Test</aaa>
							   <aaa>Test</aaa>
							   <aaa>Test</aaa>
							   <aaa>Test</aaa>
							   <aaa>Test</aaa>
							   <aaa>Test</aaa>
							   <bb test="123"><a>test</a></bb>
							   <bb test="123"><a>test</a></bb>
							   <bb test="123"><a>test</a></bb>
							   <bb test="123"><a>test</a></bb>
							   <bb test="123"><a>test</a></bb>
							   <bb test="123"><a>test</a></bb>
							   <bb test="123"><a>test</a></bb>
							   <bb test="123"><a>test</a></bb>
							   <bb test="123"><a>test</a></bb>
							   <bb test="123"><a>test</a></bb>
							   <bb test="123"><a>test</a></bb>
							   <bb test="123"><a>test</a></bb>
							   <bb test="123"><a>test</a></bb>
							   <bb test="123"><a>test</a></bb>
							   <bb test="123"><a>test</a></bb>
							   <bb test="123"><a>test</a></bb>
							   <bb test="123"><a>test</a></bb>
							   <bb test="123"><a>test</a></bb>
							   <bb test="123"><a>test</a></bb>
							   <bb test="123"><a>test</a></bb>
							 </abc>
	               return insert node $x as last into //test';
    $fullQuery  = '<query xmlns="http://basex.org/rest">';
    $fullQuery .= '<text><![CDATA[ '.$query.']]></text>';
    $fullQuery .= '</query>';    //...?>
Removing whitespaces makes it possible to send a request which is a bit longer, but not very much. Is there a solution to send requests like this, maybe in a different way? It is important to make bigger updates on my XML data with REST.
Greetings @all
CG
Christian Grün3 Jul 2012 00:53 #
Could you please paste a complete code example? Otherwise, we first have to guess how your remaining code looks like. Thanks in advance, Christian
Quoted text · MyNew EMail · 124 lines
> Hi again, > > > What do you exactly mean with "long XQuery request"? Could you provide > > us with an example that demonstrates the problem (I didn't manage to > > track it down locally)? > > I'm using PHP with cURL to call the REST service (with standard username > and password [admin, admin] for testing). Furthermore I'm using the BaseX > HTTP Server (basexhttp.bat). > > Here is some code summary (first example works well): > > > <?php > > //... > > $query = 'let $x := <abc> > <aaa>Test</aaa> > <aaa>Test</aaa> > <aaa>Test</aaa> > <aaa>Test</aaa> > <aaa>Test</aaa> > <aaa>Test</aaa> > <aaa>Test</aaa> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > </abc> > return insert node $x as last into //test'; > $fullQuery = '<query xmlns="http://basex.org/rest">'; > $fullQuery .= '<text><![CDATA[ '.$query.']]></text>'; > $fullQuery .= '</query>'; > > //... > > //set authorization stuff > > //set Content-Type header to application/xml and send a POST request to > http://localhost:8984/rest/MyDb/test.xml with $fullQuery in body. > > //This works. Example XML will be inserted. > > ?> > > > But if the XML part (let $x := ...) or the XQuery part is longer I get > this response > (and I'm authorized the same way as in the first example): > > HTTP/1.1 401 Unauthorized > > WWW-Authenticate: Basic > Content-Length: 31 > Server: Jetty(6.1.26) > > > This example does'nt work: > > <?php > > $query = 'let $x := <abc> > <aaa>Test</aaa> > <aaa>Test</aaa> > <aaa>Test</aaa> > <aaa>Test</aaa> > <aaa>Test</aaa> > <aaa>Test</aaa> > <aaa>Test</aaa> > <aaa>Test</aaa> > <aaa>Test</aaa> > <aaa>Test</aaa> > <aaa>Test</aaa> > <aaa>Test</aaa> > <aaa>Test</aaa> > <aaa>Test</aaa> > <aaa>Test</aaa> > <aaa>Test</aaa> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > <bb test="123"><a>test</a></bb> > </abc> > return insert node $x as last into //test'; > $fullQuery = '<query xmlns="http://basex.org/rest">'; > $fullQuery .= '<text><![CDATA[ '.$query.']]></text>'; > $fullQuery .= '</query>'; > > //... > > ?> > > Removing whitespaces makes it possible to send a request which is a bit > longer, but not very much. > > Is there a solution to send requests like this, maybe in a different way? > It is important to make bigger updates on my XML data with REST. > > > Greetings @all > > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >

⚡Generated with XQuery