473,805 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP/pear http put method and text/xml?

Hi,

I have a problem with the HTTP implementation of the PEAR package:
I try to PUT an XML instance to an XML database (eXist), but it always
puts a binary:

<?php
require_once "HTTP/Request.php";

$URL = 'http://ap34.ifi.inform atik.uni-goettingen.de:8 081/exist/servlet/db/may/hamlet.xml';

$req =& new HTTP_Request("" );
$req->setBasicAuth($ user, $passwd);
$req->setURL($URL) ;
$req->setMethod("PUT ");
$req->addHeader("Con tent-Type", "text/xml");
$req->addFile("hamle t.xml","/home/may/public_html/PHP/hamlet.xml", "text/xml");

$response = $req->sendRequest( );
?>

When looking into the database, there is also not the XML file, but
there is a complete HTTP request:

***
--HTTP_Request_f4 2cc34621bc820ec d46b8f6ef61eb7e
Content-Disposition: form-data; name="hamlet.xm l"; filename="hamle t.xml"
Content-Type: text/xml

<?xml version="1.0"?>
<!DOCTYPE PLAY SYSTEM "play.dtd">

<PLAY>
<TITLE>The Tragedy of Hamlet, Prince of Denmark</TITLE>
etc.
****

It seems not ot be a problem of the database, since it works well when doing
the same with python (a sample that is included into the documentation of eXist),
i.e., tha database work correctly when it receives a correct PUT.
Can anybody give me an example how HTTP PUT is applied correctly with PEAR?

THX,
Wolfgang
Jul 17 '05 #1
13 4125
Hello,

On 10/25/2004 02:29 PM, Wolfgang May wrote:
It seems not ot be a problem of the database, since it works well when doing
the same with python (a sample that is included into the documentation of eXist),
i.e., tha database work correctly when it receives a correct PUT.
Can anybody give me an example how HTTP PUT is applied correctly with PEAR?


That is the way to send files with POST. PUT is different.

I do not use PEAR classes, so I can't tell you if it can do what you
want. I use this other HTTP client class that lets you send HTTP
requests with arbitrary bodies:

http://www.phpclasses.org/httpclient

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #2
Manuel Lemos <ml****@acm.org > wrote:
Hello,

On 10/25/2004 02:29 PM, Wolfgang May wrote:
It seems not ot be a problem of the database, since it works well when doing
the same with python (a sample that is included into the documentation of eXist),
i.e., tha database work correctly when it receives a correct PUT.
Can anybody give me an example how HTTP PUT is applied correctly with PEAR?
That is the way to send files with POST. PUT is different.


I think so ...
I do not use PEAR classes, so I can't tell you if it can do what you
want. I use this other HTTP client class that lets you send HTTP
requests with arbitrary bodies:

http://www.phpclasses.org/httpclient


The site seems to be inaccessible, and as far as I understand from
http://scripts.incutio.com/httpclient/index.php (which also contains a description
of this class), this supports only get/post.

Wolfgang
Jul 17 '05 #3
Hello,

On 10/25/2004 04:47 PM, Wolfgang May wrote:
It seems not ot be a problem of the database, since it works well when doing
the same with python (a sample that is included into the documentation of eXist),
i.e., tha database work correctly when it receives a correct PUT.
Can anybody give me an example how HTTP PUT is applied correctly with PEAR?
That is the way to send files with POST. PUT is different.

I think so ...


PUT is much simpler because you just add the file to the request body.

I do not use PEAR classes, so I can't tell you if it can do what you
want. I use this other HTTP client class that lets you send HTTP
requests with arbitrary bodies:

http://www.phpclasses.org/httpclient

The site seems to be inaccessible, and as far as I understand from


It was just a temporary stop. It is accessible now.

http://scripts.incutio.com/httpclient/index.php (which also contains a description
of this class), this supports only get/post.


No, you just set the RequestMethod argument to PUT and pass file data to
the the Body request argument. Take a look at the test_http_soap. php
example for a demonstration.

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #4
Manuel Lemos <ml****@acm.org > wrote:
Hello,

On 10/25/2004 04:47 PM, Wolfgang May wrote:
It seems not ot be a problem of the database, since it works well when doing
the same with python (a sample that is included into the documentation of eXist),
i.e., tha database work correctly when it receives a correct PUT.
Can anybody give me an example how HTTP PUT is applied correctly with PEAR?

That is the way to send files with POST. PUT is different.

I think so ...


PUT is much simpler because you just add the file to the request body.


.... but not easy enough for me.
(anyway, I also did not find out how to do authorization with this package).
Sometimes a documentation would be useful (and this was one of the reasons why I tried
first to use the PEAR classes).
http://scripts.incutio.com/httpclient/index.php (which also contains a description
of this class), this supports only get/post.


.... it seems to be another PHP class, also called httpclient.
No, you just set the RequestMethod argument to PUT and pass file data to
the the Body request argument. Take a look at the test_http_soap. php
example for a demonstration.


I wanted to use these things in a course, but the results up to now
showed me that PHP seems not to be the right thing for this. Too many
similar, but different classes for the same things, with too less
documentation.

Wolfgang
Jul 17 '05 #5
Hello,

On 10/28/2004 06:57 AM, Wolfgang May wrote:
>It seems not ot be a problem of the database, since it works well when doing
>the same with python (a sample that is included into the documentation of eXist),
>i.e., tha database work correctly when it receives a correct PUT.
>Can anybody give me an example how HTTP PUT is applied correctly with PEAR?

That is the way to send files with POST. PUT is different.
I think so ...
PUT is much simpler because you just add the file to the request body.

... but not easy enough for me.
(anyway, I also did not find out how to do authorization with this package).


You just have to specify the URL like you do with a browser:

http://user:pa******@www.domain.com/uri/etc/

Sometimes a documentation would be useful (and this was one of the reasons why I tried
first to use the PEAR classes).


Right, but sometimes developers do not find enough time to produce
proper documentation. Many PEAR packages do not have proper documentation.

At least with this class you have many examples with comments in English
from which you can learn.

No, you just set the RequestMethod argument to PUT and pass file data to
the the Body request argument. Take a look at the test_http_soap. php
example for a demonstration.

I wanted to use these things in a course, but the results up to now
showed me that PHP seems not to be the right thing for this. Too many
similar, but different classes for the same things, with too less
documentation.


I don't think that as to do with PHP but rather with the fact that it
takes a lot of time to produce documentation. Since this is free
software it is hard to justify the time that it takes. Some developers
try to do it sooner rather than later, but that is not a specific
problem of PHP.

--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #6
Manuel Lemos <ml****@acm.org > wrote:
(anyway, I also did not find out how to do authorization with this package).


You just have to specify the URL like you do with a browser:

http://user:pa******@www.domain.com/uri/etc/


This is not understood by the server (same for GET, but for the PEAR classes,
setBasicAuth works fine). Although, I then experimented without access restrictions ...
No, you just set the RequestMethod argument to PUT and pass file data to
the the Body request argument. Take a look at the test_http_soap. php
example for a demonstration.


require("http.p hp");

set_time_limit( 0);
$http=new http_class;
$url="...";
$http->GetRequestArgu ments($url,$arg uments);
$arguments["RequestMet hod"]="PUT";
$arguments["Headers"]["Content-Type"]="text/xml; charset=\"utf-8\"";
$arguments["Body"]="<?xml version='1.0' encoding='UTF-8'?><name>bla</name>";
+ and the remaining part of the soap test
.... and it answers:

***
Response body:

HTTP/1.1 200 OK
Date: Mon, 01 Nov 2004 16:53:28 GMT
Server: Jetty/4.1.4 (Linux 2.4.20-gk20030509 i386)
Servlet-Engine: Jetty/4.1.4 (Servlet 2.3; JSP 1.2; java 1.4.2)
Content-Type: text/xml; charset=UTF-8
Transfer-Encoding: chunked

2b
Document bla.xml stored as binary resource.
0
***

and puts the document as a *binary*.

It's not a problem of the server, since HTTP PUT with python works.
Can you tell me what I am still doing wrong?

Wolfgang

Jul 17 '05 #7
Hello,

On 11/01/2004 02:58 PM, Wolfgang May wrote:
(anyway, I also did not find out how to do authorization with this package).


You just have to specify the URL like you do with a browser:

http://user:pa******@www.domain.com/uri/etc/

This is not understood by the server (same for GET, but for the PEAR classes,
setBasicAuth works fine). Although, I then experimented without access restrictions ...


I was not talking about PEAR classes. As I said I do not use them.

You can use such type of URL with the HTTP client class that I mentioned.

No, you just set the RequestMethod argument to PUT and pass file data to
the the Body request argument. Take a look at the test_http_soap. php
example for a demonstration.

require("http.p hp");

set_time_limit( 0);
$http=new http_class;
$url="...";
$http->GetRequestArgu ments($url,$arg uments);
$arguments["RequestMet hod"]="PUT";
$arguments["Headers"]["Content-Type"]="text/xml; charset=\"utf-8\"";
$arguments["Body"]="<?xml version='1.0' encoding='UTF-8'?><name>bla</name>";
+ and the remaining part of the soap test
... and it answers:

***
Response body:

HTTP/1.1 200 OK
Date: Mon, 01 Nov 2004 16:53:28 GMT
Server: Jetty/4.1.4 (Linux 2.4.20-gk20030509 i386)
Servlet-Engine: Jetty/4.1.4 (Servlet 2.3; JSP 1.2; java 1.4.2)
Content-Type: text/xml; charset=UTF-8
Transfer-Encoding: chunked

2b
Document bla.xml stored as binary resource.
0
***

and puts the document as a *binary*.

It's not a problem of the server, since HTTP PUT with python works.
Can you tell me what I am still doing wrong?


Nothing. Isn't that the expected response?
--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #8
Manuel Lemos <ml****@acm.org > wrote:
Hello,

On 11/01/2004 02:58 PM, Wolfgang May wrote:
(anyway, I also did not find out how to do authorization with this package).

You just have to specify the URL like you do with a browser:

http://user:pa******@www.domain.com/uri/etc/

This is not understood by the server (same for GET, but for the PEAR classes,
setBasicAuth works fine). Although, I then experimented without access restrictions ...


I was not talking about PEAR classes. As I said I do not use them.

You can use such type of URL with the HTTP client class that I mentioned.


No, as I said, the server does not understand them.
But, it understands authenthificati on via the setBasicAuth() method as provided by
e.g. the PEAR classes. The package you mentioned does -at least as far as I can see
from the documentation- not support this.
$url="...";
$http->GetRequestArgu ments($url,$arg uments);
$arguments["RequestMet hod"]="PUT";
$arguments["Headers"]["Content-Type"]="text/xml; charset=\"utf-8\"";
$arguments["Body"]="<?xml version='1.0' encoding='UTF-8'?><name>bla</name>";
+ and the remaining part of the soap test
... and it answers:

***
Response body:

HTTP/1.1 200 OK
Date: Mon, 01 Nov 2004 16:53:28 GMT
Server: Jetty/4.1.4 (Linux 2.4.20-gk20030509 i386)
Servlet-Engine: Jetty/4.1.4 (Servlet 2.3; JSP 1.2; java 1.4.2)
Content-Type: text/xml; charset=UTF-8
Transfer-Encoding: chunked

2b
Document bla.xml stored as binary resource.
0
***

and puts the document as a *binary*.

It's not a problem of the server, since HTTP PUT with python works.
Can you tell me what I am still doing wrong?


Nothing. Isn't that the expected response?


No, with specifying "ContentType='t ext/xml'" I would expect that it
puts it as XML, not as a binary. When putting it as a binary, the XML
database system does not recognize it. The same thing works
well, when doing HTTP PUT by python or Java, so the problem is not due
to the receiving system.

Wolfgang
Jul 17 '05 #9
Hello,

On 11/04/2004 06:45 AM, Wolfgang May wrote:
>(anyway, I also did not find out how to do authorization with this package).

You just have to specify the URL like you do with a browser:

http://user:pa******@www.domain.com/uri/etc/
This is not understood by the server (same for GET, but for the PEAR classes,
setBasicAu th works fine). Although, I then experimented without access restrictions ...


I was not talking about PEAR classes. As I said I do not use them.

You can use such type of URL with the HTTP client class that I mentioned.

No, as I said, the server does not understand them.
But, it understands authenthificati on via the setBasicAuth() method as provided by
e.g. the PEAR classes. The package you mentioned does -at least as far as I can see
from the documentation- not support this.


I think you are confused. The class from
http://www.phpclasses.org/httpclient does support that when you call
GetRequestArgum ents function and it does not come with documentation.
Are you sure you are seeing the same class?

$url="...";
$http->GetRequestArgu ments($url,$arg uments);
$arguments["RequestMet hod"]="PUT";
$arguments["Headers"]["Content-Type"]="text/xml; charset=\"utf-8\"";
$arguments["Body"]="<?xml version='1.0' encoding='UTF-8'?><name>bla</name>";
+ and the remaining part of the soap test
... and it answers:

***
Response body:

HTTP/1.1 200 OK
Date: Mon, 01 Nov 2004 16:53:28 GMT
Server: Jetty/4.1.4 (Linux 2.4.20-gk20030509 i386)
Servlet-Engine: Jetty/4.1.4 (Servlet 2.3; JSP 1.2; java 1.4.2)
Content-Type: text/xml; charset=UTF-8
Transfer-Encoding: chunked

2b
Document bla.xml stored as binary resource.
0
***

and puts the document as a *binary*.

It's not a problem of the server, since HTTP PUT with python works.
Can you tell me what I am still doing wrong?


Nothing. Isn't that the expected response?

No, with specifying "ContentType='t ext/xml'" I would expect that it
puts it as XML, not as a binary. When putting it as a binary, the XML
database system does not recognize it. The same thing works
well, when doing HTTP PUT by python or Java, so the problem is not due
to the receiving system.


And what message appears when you do HTTP PUT with Python or Java?

Another thing that is odd is the httpclient class handles chunked
transfer encoding correctly, so you should not see those hexadecimal
charcters (2b 0) in the response. Are you sure that is the same
response that is returned when you use the httpclient class or that is
the response when using the PEAR class?
--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2388
by: Arne Kösling | last post by:
Hi, PEAR:SOAP is not working. I've tried so many examples now and the only one that works, is that amazon example, which is too complex for me to understand. I am so reliant on the Web Services with SOAP .... and I can t get it work. :'-(
3
7248
by: junkmail | last post by:
on a win 2k server apparantly it is saying i dont have it. or it cant find it. im using mySQL 4.1 php 4.3.x apache 3.0.53 im new to php and am doing some tutorials, but when i run the sripts it tells mea it can not run pear/soap, because it can not be found.the book im learning form does not tell me how to install or configure this extension. so now im looking for help.
0
1639
by: Michel P. | last post by:
Hi, I'm trying to install the bcompiler extension, under PHP 5.0.4 / Apache / FreeBSD, but can't finalize the install process... Has anybody allready done it ? I'm using the recommended method (in the file "package.xml", in the .tgz file downloaded from PECL): using Pear ("For install instructions see the manual at pear.php.net").
0
1918
by: Samuel Zallocco | last post by:
Hi all, I've a problem with PHP5 + PEAR::SOAP. I Have the following 2 script that implements a simple web service: The Server Code running on WinXP + PHP5 + Apache 2.x: ---------------------------------------------------- <?php require_once('SOAP/Server.php'); require_once('SOAP/Disco.php');
5
4056
by: kd | last post by:
I need pear for an offline laptop so the standard install method is no possible. Any suggestions as to how to install pear on the laptop, does anyone have a zip of all pear packages that I can download ? Thanks
1
7843
by: CSTechie | last post by:
I've been battling to install PEAR on Windows XP now for too long. I am not sure what I need to do. When I run go-pear.php from the command line, I get the error message as shown at the end. I included everything in case there is something there that's helpful. I'm trying to install PEAR so that I can use PHPUnit. Thanks for the help!!!!
4
2134
by: awebguynow | last post by:
Re: only got "pear.old_bat" I had a previous post ".. Upgrade Methods ..." and so far I've gotten around most thorny issues, including patching php5.1.4 with php5apache2_2.dll so I can run it as module with Apache2.2.3 I need a educated response from a PEAR developer, if possible My 1st run go-pear died because I exceeded "maximum execution time" while researching the 1st ?
5
4521
by: Dan Fulbright | last post by:
I'm trying to install PHP 5.2.2 on Windows, but I keep getting errors when running go-pear.bat: mmap cache can't open phar://go-pear.phar/index.php mmap cache can't open phar://go-pear.phar/PEAR/Start/CLI.php mmap cache can't open phar://go-pear.phar/PEAR/Start.php There are 20 of these lines. After continuing through the script, it dies with this error:
5
3569
by: jmark | last post by:
I need some assistance on how to create a select statement using PEAR DB or MySQL with the LIKE function. That is I am looking of how I can get statement like this work. SELECT * FROM customer WHERE name LIKE '%?'
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10613
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.