cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastien Arbogast <>
Subject Re: Cocoon and Axis
Date Fri, 03 Jun 2005 22:04:53 GMT
I almost got it !!! (Axis is great to use !... I love it when API's
are so intuitive)
I just miss a small part to send the answer message I've built back to
the client. Here is the new cocoonWS function I came up with (with
plenty of debugging code in the middle :-P)

function webservice(){
    var module = cocoon.parameters["module"];
    clog("module is:" + module + "\n");

	//getting the envelope out of the request (can be done only once)
	var soapEnvelope = new;
	cocoon.processPipelineTo("soapEnvelope", null, soapEnvelope);
	clog("Request was:\n" + soapEnvelope + "\n");
	var message = new org.apache.axis.Message(soapEnvelope.toString());
	clog("Message length was: " + message.getContentLength() + "\n");
	var soapPart = message.getSOAPPart();
	clog("soapPart was :\n" + soapPart + "\n");
	var envelope = soapPart.getEnvelope();
	clog("envelope was :\n" + envelope + "\n");
	var body = envelope.getBody();
	clog("body was :\n" + body + "\n");
	var it = body.getChildElements();
	var messageContent =;
	clog("messageContent was :\n" + messageContent + "\n");
    var soapMethod = messageContent.getElementName().getLocalName();
    clog("soapMethod was : " + soapMethod + "\n");

     * Now that we have the method, we generate the according parameters and 
     * execute the code for the called method	
	if(soapMethod == "echo"){
		clog("echo called");

        //generate the parameter
        var soapParameter = messageContent.getValue();
        clog("soapParameter: " + soapParameter);
        //process the method (echo in this case)
		 * Here we compute something e.g. some businessprocess
		 * can be executed (sendMail, ftpUpload,...)
		 * for the echo Method it would be:
		 * //var answer = parameter;
		 * but we put this right in the answer.
		var answerEnvelope = new SOAPEnvelope(); 
		var answerContent = new SOAPBodyElement(new
		clog("answerEnvelope was :\n" + answerEnvelope + "\n");

        //send the answer
        //THE CONTENT OF answerContent BACK TO THE USER

	else { /* here you can add more methods */

	    //setting the answer if no method matched
	    //TODO in this case we should generate a SOAP-FAULT
	    var answer = "The method you have called is not understood by
this server. " +
		cocoon.sendPage("soapAnswer", {"answer":answer});
		clog("no method matched, sending error-statment");

Any ideas out there to replace my "uppercase desperate call" with
something that actually works ?

BTW this works perfectly and it's much cleaner than the previous
approach (no more JXTemplate and XSLT to extract SOAP data) but I
still lose HTTP headers from the initial request because I build a
message from the received SOAP envelope instead of getting a
MessageContent built from the servlet request. So does anyone have an
idea for that... ?

Sebastien ARBOGAST

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message