W3C home > Mailing lists > Public > www-lib@w3.org > January to March 2001

SOAP Listener

From: Halliley, Tom <Tom_Halliley@compuware.com>
Date: Fri, 9 Feb 2001 12:27:18 -0500 (EST)
Message-ID: <8D81DA9D264CD311A60C0008C75D553B045FDB07@cwus-dtw-pri02.compuware.com>
To: "'www-lib@w3.org'" <www-lib@w3.org>
I'm trying to write a SOAP Listener using libwww.  To do so, I've modified
the 
listen.c example and added the XML parsing stuff from the showxml.c example,

however, nothing happens.  That is, only the initial message "Listening on
port 90..." 
comes out.  If I use the generic listen.c, I receive the SOAP payload just
fine.

The questionable code is shown below.  Is the attachment of the parser
troublesome to
HTServeAbsolute?  If I set a breakpoint at HTXML_newInstance, I can see that
I never get there when the payload arrives.

Thanks for any ideas,
Tom



/*** SNIP

     Left out parser callbacks, etc.

     SNIP ***/

PUBLIC BOOL SOAP_ListenForRequest(const int onPort)
{    
  ListenTool * ms = ListenTool_new();
  int status = HT_ERROR;
  int arg = 0;

  HTLibInit(APP_NAME, APP_VERSION);

#if (_DEBUG)
  HTSetTraceMessageMask("sop");
#endif

  /* Set up default event loop */
  HTEventInit();

  /* Need our own trace and print functions */
  HTPrint_setCallback(printer);
  HTTrace_setCallback(tracer);

  /* Add our own filter to handle termination */
  HTNet_addAfter(terminate_handler, NULL, NULL, HT_ALL, HT_FILTER_LAST);

  /* Register our new XML Instance handler */
  HTXMLCallback_registerNew (HTXML_newInstance, NULL);

  /* Setup a timeout on the request for 15 secs */
  HTHost_setEventTimeout(15000);

  ms->port = onPort;

  /* Set up a tool to listen on this port */
  if (ms->port >= 0) {
	HTList* charsets  = HTList_new();
	HTList* encodings = HTList_new();

    /* Register TCP as the transport */
    HTTransport_add("tcp", HT_TP_SINGLE, HTReader_new, HTWriter_new);

    /* Register the "noop" application layer protocol for reading */
    HTProtocol_add("noop", "tcp", ms->port, NO, NULL, HTLoadSocket);

    /* Set up the request */
    ms->request = HTRequest_new();
    HTRequest_setOutputFormat(ms->request, HTAtom_for("text/xml"));
    HTRequest_setOutputStream(ms->request,
                              HTFWriter_new(ms->request, OUTPUT, YES));

    /* Start listening on the socket */
    if ((status = HTServeAbsolute("noop://localhost", ms->request)) == NO) {
      HTPrint("Can't listen on port %d\n", ms->port);
      Cleanup(ms, -1);
    } else {
	HTPrint("Listening on port %d\n", ms->port);
    }

    /* Go into the event loop... */
    if (status == YES) HTEventList_newLoop();
  }

  Cleanup(ms, 0);
  return YES;
}


---------------------------------
Tom_Halliley@Compuware.com
Software Architect
Common Technologies Group
248-737-7300 ext. 10117
  
Received on Monday, 12 February 2001 03:08:49 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:38 GMT