W3C home > Mailing lists > Public > www-lib@w3.org > July to September 2001

Re: Requests to a servlet

From: SMIGIELSKI ANDREAS <andreas.smigielski@bwg.sbs.de>
Date: 25 Sep 2001 08:45:45 +0200
To: "Mikesell, Dave" <dmikesell@cas.org>
Cc: "'www-lib@w3.org'" <www-lib@w3.org>
Message-Id: <1001400345.18792.29.camel@pc86.bwg.sbs.de>
Hello Dave,

you need a Function like HTPostAnchorToChunk to post the XML Data to the
HTTP server, it looks like this:

PUBLIC HTChunk * HTPostAnchorToChunk (HTParentAnchor *  source,
                         HTAnchor *             destination,
                         HTRequest *            request)
  if (source && destination && request) {
    HTChunk * chunk = NULL;
    HTStream * target = HTStreamToChunk(request, &chunk, 0);
    HTRequest_setOutputStream(request, target);
    if (HTPostAnchor(source, destination, request) != NULL)
      return chunk;
    else {
      return NULL;
  return NULL;

Then you can create an XML request:

  request = HTRequest_new();
  HTRequest_setOutputFormat(request, HTAtom_for("text/xml"));

  anchor = HTAnchor_findAddress(dst_str);

  /* dst_str is the Destination Address: http://www.xxx */
  /* xml_data is the XML Data you would like to send */

  src = HTTmpAnchor(NULL);
  HTAnchor_setDocument(src, xml_data);
  HTAnchor_setFormat(src, HTAtom_for("text/xml"));
  HTAnchor_setCharset(src, HTAtom_for("UTF-8"));
  HTAnchor_setLength(src, strlen(xml_data));

after that you can POST the XML Data and parse the returned XML string:

  HTChunk * chunk;
  xmlDocPtr *rs;

  chunk = HTPostAnchorToChunk(src, anchor, request);
  /* If chunk != NULL then we have the data */
  if (chunk) {
    string = HTChunk_toCString(chunk);
    /* HTPrint("%s", string ? string : "no text\n"); */
    if (string) {
       *rs = xmlParseMemory(string, sizeof(string));

*rs contains the returned XML Tree.


Am Mon, 2001-09-24 um 16.25 schrieb 1001341558:
> Greetings.  We have a client library written in C that provides access
to our J2EE environment.  Without going into to much detail, each
library function causes an XML message to be sent over a socket to the
server, which in turn parses the message, invokes the proper J2EE
service, and then sends an XML response back to the client.  We would
like to replace our socket/home-grown protocol with HTTP using libwww. 
This would involve sending raw XML to a servlet and waiting for the
servlet to send back an XML response.
> Is this possible using libwww?  From what I can tell, the closest thing to what we need is HTPostFormAnchorToChunk(), but we don't have a "form" per se...just XML.  Any insight would be greatly appreciated.  Thank you.
> Dave

Received on Tuesday, 25 September 2001 02:46:29 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:33:54 UTC