httpclient

View: New views
5 Messages — Rating Filter:   Alert me  

httpclient

by Wolfgang Freis-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I am trying to write a POST request to a server. I do get a response but
it is clear that the server was not able to read the parameters I
posted.  The documentation is silent on what format the payload needs to
be.  In the mailing list I only found examples that used variables,
which doesn't help.

Could someone please enlighten me on the payload format?

Thanks in advance,
Wolfgang

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: httpclient

by gilles-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Wolfgang,

here's a code snippet using httpclient I was using to post a XUpdate query on a
document in an eXist database. (raw posting).

hope it helps.

Gilles


------
     // requete XUpdate
     String xuQuery="<?xml version=\"1.0\"?><xu:insert-before
xmlns:xu=\"http://www.xmldb.org/xupdate\" select=\"//mdFileID\"><xu:comment>Test
XUpdate (comment)</xu:comment></xu:insert-before>" ;
     String
URL="http://host:8080/exist/servlet/db/document.xml" ;
     PostMethod httppost = new PostMethod(URL);
     httppost.setRequestBody(xuQuery);
     // chaine d'authentification generee a partir du username/password
     String authString= BasicScheme.authenticate(new UsernamePasswordCredentials
("user","password") ) ;
     httppost.addRequestHeader(HttpAuthenticator.WWW_AUTH_RESP,authString) ;
     HttpClient client= new HttpClient();
     // execution de la requete
     try {
   client.executeMethod(httppost);
     } catch (IOException ioe) {
       System.out.println("IOE : "+ioe.getMessage()) ;
    }
-----

Wolfgang Freis a écrit :

> I am trying to write a POST request to a server. I do get a response but
> it is clear that the server was not able to read the parameters I
> posted.  The documentation is silent on what format the payload needs to
> be.  In the mailing list I only found examples that used variables,
> which doesn't help.
>
> Could someone please enlighten me on the payload format?
>
> Thanks in advance,
> Wolfgang
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Exist-open mailing list
> Exist-open@...
> https://lists.sourceforge.net/lists/listinfo/exist-open
>


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Parent Message unknown Re: httpclient

by Adam Retter-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Let me just understand this completely -

You are trying to POST an XUpdate, so that it executes against a
resource or collection?



2008/6/30 Wolfgang Freis <freis.w@...>:

>
> Adam,
>
> can you clarify the POST method for me?  I find no reference in the
> documentation what the structure of the 'payload' needs to be.  I have no
> problem sending GET requests, but I need to write a POST method with request
> parameters and can't figure out what the format of the 'payload' node needs
> to be.
>
>
> Thanks in advance,
> Wolfgang
>



--
Adam Retter

eXist Developer
{ England }
adam@...
irc://irc.freenode.net/existdb

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Parent Message unknown Re: httpclient

by Andrzej Jan Taramina :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Wolfgang asked:

> Could someone please enlighten me on the payload format?

The actual format of the payload depends on the server that is receiving it.

That being said, currently httpclient only allows the payload to be an XML
document, and this implies that the receiving server needs to be able to accept
an XML document as input.

In other words, currently there is no way to specify a list of individual POST
parameters of the form parm=value in the payload, as you would with a GET.

--
Andrzej Taramina
Chaeron Corporation: Enterprise System Solutions
http://www.chaeron.com

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open

Re: httpclient

by Adam Retter-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Wolfgang,

Andrzej is correct, there is currently no way to add POST parameters,
however this would be simple for us to do.

In the mean time however, have you considered placing the parameters
on the querystring, a lot of Server implementations do not actually
differentiate between paremeters on the querystring and POST
parameters (for example Java).

e.g. POST to a url of something like
http://blah.dom/blah/script?param1=1¶m2=param2

That may well work for you.

Cheers Adam.


2008/6/30 Andrzej Jan Taramina <andrzej@...>:

>
> Wolfgang asked:
>
>> Could someone please enlighten me on the payload format?
>
> The actual format of the payload depends on the server that is receiving it.
>
> That being said, currently httpclient only allows the payload to be an XML
> document, and this implies that the receiving server needs to be able to accept
> an XML document as input.
>
> In other words, currently there is no way to specify a list of individual POST
> parameters of the form parm=value in the payload, as you would with a GET.
>
> --
> Andrzej Taramina
> Chaeron Corporation: Enterprise System Solutions
> http://www.chaeron.com
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Exist-open mailing list
> Exist-open@...
> https://lists.sourceforge.net/lists/listinfo/exist-open
>



--
Adam Retter

eXist Developer
{ England }
adam@...
irc://irc.freenode.net/existdb

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open
LightInTheBox - Buy quality products at wholesale price