You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Sebastien Arbogast <se...@gmail.com> on 2005/06/03 19:13:45 UTC

Cocoon and Axis

Hi there,

I'm trying to find a clean alternative to use Cocoon as a webservice
server using Axis as a library. So I see two solutions right now :
1 - using Jan's approach with a StreamGenerator
(http://wiki.apache.org/cocoon/WebServiceServer) to get the SOAP
message in a ByteArrayOutputStream and then use that to build an Axis
message I can manipulate from flowscript
2 - or even better, it would be great if I could use Cocoon servlet as
an HTTP listener (equivalent to the Axis servlet) to get directly a
Message Context somewhere.

Does anybody have an idea of how I can integrate Axis inside Cocoon ?

And I found that
(http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/components/axis/SoapServer.html)
in the API docs... would it be useful ? how ?

Thx in advance.

-- 
Sebastien ARBOGAST

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon and Axis

Posted by Sebastien Arbogast <se...@gmail.com>.
2005/6/3, Davanum Srinivas <da...@gmail.com>:
> com.sun.xml.messaging.saaj is NOT in axis

Yep I know... but anyway I finally found a solution. I don't fully
understand how it works but the solution was to use joose method
advocated in Jan's approach, with a JXTemplate (with an inject macro)
and a stringToSAX function to generate SAX events from a String.

I had begun to write it down for the Wiki but FF crashed and I lost
everything (:-|) so I don't have the courage to write it again right
now. It might be an interesting subject for one of our first tutorials
on Planet Cocoon, in order to test our workflow process ;-)

If anyone needs more information about how I used Axis API's to access
SOAP data, feel free to send me an email and I'll give you details.

Now that works but I still need to solve the mystery of the
SOAPServerImpl component (which appears to be properly configured in
cocoon.xconf). If anyone could give me more details about that one, it
would be great...

--
Sebastien ARBOGAST

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon and Axis

Posted by Sebastien Arbogast <se...@gmail.com>.
2005/6/3, Davanum Srinivas <da...@gmail.com>:
> com.sun.xml.messaging.saaj is NOT in axis

Yep I know... but anyway I finally found a solution. I don't fully
understand how it works but the solution was to use joose method
advocated in Jan's approach, with a JXTemplate (with an inject macro)
and a stringToSAX function to generate SAX events from a String.

I had begun to write it down for the Wiki but FF crashed and I lost
everything (:-|) so I don't have the courage to write it again right
now. It might be an interesting subject for one of our first tutorials
on Planet Cocoon, in order to test our workflow process ;-)

If anyone needs more information about how I used Axis API's to access
SOAP data, feel free to send me an email and I'll give you details.

Now that works but I still need to solve the mystery of the
SOAPServerImpl component (which appears to be properly configured in
cocoon.xconf). If anyone could give me more details about that one, it
would be great...

--
Sebastien ARBOGAST

Re: Cocoon and Axis

Posted by Sebastien Arbogast <se...@gmail.com>.
2005/6/3, Davanum Srinivas <da...@gmail.com>:
> can u get cocoon.response's outputstream and use the messages
> writeTo method?

Technically yes I can do something like that :

cocoon.response.setContentType("text/xml");
       var os = cocoon.response.getOutputStream();
       os.println(answerContent.toString());

But I keep getting this exception:
com.sun.xml.messaging.saaj.SOAPExceptionImpl: Invalid
Content-Type:text/html. Is this an error message instead of a SOAP
response?

It seems a bit rough to me : we don't do everything that the XML
serializer does. And what if I want to apply a transformation to my
document before I send it, like some i18n transformation for example.
There should be a simple solution to do that sort of thing... maybe a
suggestion for a method to add to the cocoon object hmmm ?

BTW I had completely forgotten I could access HttpServletRequest and
HttpServletResponse from flowscript using the cocoon object. Maybe it
would be enough to rebuild the MessageContext object and forward it to
some Axis handlers... WDYT ?

--
Sebastien ARBOGAST

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon and Axis

Posted by Sebastien Arbogast <se...@gmail.com>.
2005/6/3, Davanum Srinivas <da...@gmail.com>:
> can u get cocoon.response's outputstream and use the messages
> writeTo method?

Technically yes I can do something like that :

cocoon.response.setContentType("text/xml");
       var os = cocoon.response.getOutputStream();
       os.println(answerContent.toString());

But I keep getting this exception:
com.sun.xml.messaging.saaj.SOAPExceptionImpl: Invalid
Content-Type:text/html. Is this an error message instead of a SOAP
response?

It seems a bit rough to me : we don't do everything that the XML
serializer does. And what if I want to apply a transformation to my
document before I send it, like some i18n transformation for example.
There should be a simple solution to do that sort of thing... maybe a
suggestion for a method to add to the cocoon object hmmm ?

BTW I had completely forgotten I could access HttpServletRequest and
HttpServletResponse from flowscript using the cocoon object. Maybe it
would be enough to rebuild the MessageContext object and forward it to
some Axis handlers... WDYT ?

--
Sebastien ARBOGAST

Re: Cocoon and Axis

Posted by Davanum Srinivas <da...@gmail.com>.
can u get cocoon.response's outputstream and use the messages writeTo method? 

On 6/3/05, Sebastien Arbogast <se...@gmail.com> wrote:
> 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 java.io.ByteArrayOutputStream();
>         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 = it.next();
>         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
> PrefixedQName("cocoonWS","result","cws"));
>                 answerContent.addTextNode(soapParameter);
>                 answerEnvelope.addBodyElement(answerContent);
>                 clog("answerEnvelope was :\n" + answerEnvelope + "\n");
> 
>         //send the answer
>         //AND THE PROBLEM IS HERE CAUSE I DON'T KNOW HOW TO SEND
>         //THE CONTENT OF answerContent BACK TO THE USER
> 
>         clog("done.");
>         return;
>         }
>         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. " +
>                                         "Sorry!";
>                 cocoon.sendPage("soapAnswer", {"answer":answer});
>                 clog("no method matched, sending error-statment");
>             return;
>     }
> }
> 
> 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
> 


-- 
Davanum Srinivas - http://webservices.apache.org/~dims/

Re: Cocoon and Axis

Posted by Davanum Srinivas <da...@gmail.com>.
can u get cocoon.response's outputstream and use the messages writeTo method? 

On 6/3/05, Sebastien Arbogast <se...@gmail.com> wrote:
> 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 java.io.ByteArrayOutputStream();
>         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 = it.next();
>         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
> PrefixedQName("cocoonWS","result","cws"));
>                 answerContent.addTextNode(soapParameter);
>                 answerEnvelope.addBodyElement(answerContent);
>                 clog("answerEnvelope was :\n" + answerEnvelope + "\n");
> 
>         //send the answer
>         //AND THE PROBLEM IS HERE CAUSE I DON'T KNOW HOW TO SEND
>         //THE CONTENT OF answerContent BACK TO THE USER
> 
>         clog("done.");
>         return;
>         }
>         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. " +
>                                         "Sorry!";
>                 cocoon.sendPage("soapAnswer", {"answer":answer});
>                 clog("no method matched, sending error-statment");
>             return;
>     }
> }
> 
> 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
> 


-- 
Davanum Srinivas - http://webservices.apache.org/~dims/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon and Axis

Posted by Sebastien Arbogast <se...@gmail.com>.
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 java.io.ByteArrayOutputStream();
	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 = it.next();
	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
PrefixedQName("cocoonWS","result","cws"));
		answerContent.addTextNode(soapParameter);
		answerEnvelope.addBodyElement(answerContent);
		clog("answerEnvelope was :\n" + answerEnvelope + "\n");

        //send the answer
        //AND THE PROBLEM IS HERE CAUSE I DON'T KNOW HOW TO SEND
        //THE CONTENT OF answerContent BACK TO THE USER

        clog("done.");
        return;
	} 
	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. " +
					"Sorry!";         
		cocoon.sendPage("soapAnswer", {"answer":answer});
		clog("no method matched, sending error-statment");
	    return;
    }
}

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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon and Axis

Posted by Sebastien Arbogast <se...@gmail.com>.
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 java.io.ByteArrayOutputStream();
	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 = it.next();
	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
PrefixedQName("cocoonWS","result","cws"));
		answerContent.addTextNode(soapParameter);
		answerEnvelope.addBodyElement(answerContent);
		clog("answerEnvelope was :\n" + answerEnvelope + "\n");

        //send the answer
        //AND THE PROBLEM IS HERE CAUSE I DON'T KNOW HOW TO SEND
        //THE CONTENT OF answerContent BACK TO THE USER

        clog("done.");
        return;
	} 
	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. " +
					"Sorry!";         
		cocoon.sendPage("soapAnswer", {"answer":answer});
		clog("no method matched, sending error-statment");
	    return;
    }
}

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

Re: Cocoon and Axis

Posted by Sebastien Arbogast <se...@gmail.com>.
2005/6/3, Davanum Srinivas <da...@gmail.com>:
> yep. makes it VERY clear. need a bit of time to think about it. note
> that it may be easier to add attachment support (if it is not there
> already) to cocoon than to integrate Axis and Cocoon on the
> server-side.

thank you very much to take time to think about it. I really appreciate that.

In the meantime, does someone have an idea how I can use
SoapServerImpl in my application ? According to the API documentation
it's quite recent (last committed on 2005-01-30 by Carsten Ziegeler),
written by Marcus Crafter. Any idea ?

-- 
Sebastien ARBOGAST

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon and Axis

Posted by Sebastien Arbogast <se...@gmail.com>.
2005/6/3, Davanum Srinivas <da...@gmail.com>:
> yep. makes it VERY clear. need a bit of time to think about it. note
> that it may be easier to add attachment support (if it is not there
> already) to cocoon than to integrate Axis and Cocoon on the
> server-side.

thank you very much to take time to think about it. I really appreciate that.

In the meantime, does someone have an idea how I can use
SoapServerImpl in my application ? According to the API documentation
it's quite recent (last committed on 2005-01-30 by Carsten Ziegeler),
written by Marcus Crafter. Any idea ?

-- 
Sebastien ARBOGAST

Re: Cocoon and Axis

Posted by Davanum Srinivas <da...@gmail.com>.
yep. makes it VERY clear. need a bit of time to think about it. note
that it may be easier to add attachment support (if it is not there
already) to cocoon than to integrate Axis and Cocoon on the
server-side.

On 6/3/05, Sebastien Arbogast <se...@gmail.com> wrote:
> BTW I forgot to mention something. The purpose of my webservices is
> not to create some RPC interface to my business code. In fact I want
> to use the document style to generate XML documents using Cocoon
> sitemap facilities and feed them into my SOAP responses. And of course
> I want to use parameters I can extract from the SOAP request message
> body as parameters for the code that generates those documents. For
> example I receive this kind of SOAP request :
> 
> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
>    <SOAP-ENV:Header/>
>    <SOAP-ENV:Body>
>        <wifilist>
>            <location x="23.764578" y="87.875468" z=".7688"/>
>            <range radius="1000" unit="meters"/>
>        </wifilist>
>    </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
> 
> And I want to send back a SOAP response with a graphic map in
> attachment spotting all the wifi hotspots 1000meters around the
> specified position. Maybe something like :
> 
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>    <soapenv:Body>
>        <html soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
>            <body>
>                <img src="map.gif"/>
>            </body>
>        </html>
>    </soapenv:Body>
> </soapenv:Envelope>
> 
> With map.gif in attachment of course.
> I know it's not very frequent as a usage of webservices but I need
> something like that.
> I hope it gives you a better idea of what I'm trying to achieve...
> 
> --
> Sebastien ARBOGAST
> 


-- 
Davanum Srinivas - http://webservices.apache.org/~dims/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon and Axis

Posted by Davanum Srinivas <da...@gmail.com>.
yep. makes it VERY clear. need a bit of time to think about it. note
that it may be easier to add attachment support (if it is not there
already) to cocoon than to integrate Axis and Cocoon on the
server-side.

On 6/3/05, Sebastien Arbogast <se...@gmail.com> wrote:
> BTW I forgot to mention something. The purpose of my webservices is
> not to create some RPC interface to my business code. In fact I want
> to use the document style to generate XML documents using Cocoon
> sitemap facilities and feed them into my SOAP responses. And of course
> I want to use parameters I can extract from the SOAP request message
> body as parameters for the code that generates those documents. For
> example I receive this kind of SOAP request :
> 
> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
>    <SOAP-ENV:Header/>
>    <SOAP-ENV:Body>
>        <wifilist>
>            <location x="23.764578" y="87.875468" z=".7688"/>
>            <range radius="1000" unit="meters"/>
>        </wifilist>
>    </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
> 
> And I want to send back a SOAP response with a graphic map in
> attachment spotting all the wifi hotspots 1000meters around the
> specified position. Maybe something like :
> 
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>    <soapenv:Body>
>        <html soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
>            <body>
>                <img src="map.gif"/>
>            </body>
>        </html>
>    </soapenv:Body>
> </soapenv:Envelope>
> 
> With map.gif in attachment of course.
> I know it's not very frequent as a usage of webservices but I need
> something like that.
> I hope it gives you a better idea of what I'm trying to achieve...
> 
> --
> Sebastien ARBOGAST
> 


-- 
Davanum Srinivas - http://webservices.apache.org/~dims/

Re: Cocoon and Axis

Posted by Chris Holmes <ch...@gmail.com>.
If you're looking to do mapping stuff there is a whole body of
specifications, and open source implementations, to do exactly what
you want.  To get a map you can use the Web Map Service specification
- there is a Java implementation called GeoServer -
http://geoserver.sourceforge.net and a strong C implementation called
MapServer - http://mapserver.gis.umn.edu/  The specs are done by the
Open Geospatial Consortium - http://opengeospatial.org - and the WMS
one is quite mature, at the time they developed it SOAP was quite
young - they're making soap bindings for their web services now.  WMS
spec is here: http://portal.opengeospatial.org/files/?artifact_id=5316

Unfortunately there is no real good intro to the WMS spec, when I find
time I may just do one.  There is a not very good 'cookbook' here:
http://www.opengeospatial.org/resources/?page=cookbooks  And I'm happy
to answer any further questions on the geoserver lists.

A WMS will easily return maps as gifs, or other formats, and indeed
there are many clients that will allow you to zoom and navigate, and
to overlay the map you're requesting with maps from other WMS servers.
 You make requests generally with key value pairs in the url, or
through XML post requests.

(sorry for the random post without introducing myself - I'm mostly
lurking on the list for the discussion of micro kernel stuff - we're
thinking about many similar issues in the context of geoserver,
wanting a plug-in architecture for geospatial applications.)

best regards,

Chris

On 6/3/05, Sebastien Arbogast <se...@gmail.com> wrote:
> BTW I forgot to mention something. The purpose of my webservices is
> not to create some RPC interface to my business code. In fact I want
> to use the document style to generate XML documents using Cocoon
> sitemap facilities and feed them into my SOAP responses. And of course
> I want to use parameters I can extract from the SOAP request message
> body as parameters for the code that generates those documents. For
> example I receive this kind of SOAP request :
> 
> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
>    <SOAP-ENV:Header/>
>    <SOAP-ENV:Body>
>        <wifilist>
>            <location x="23.764578" y="87.875468" z=".7688"/>
>            <range radius="1000" unit="meters"/>
>        </wifilist>
>    </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
> 
> And I want to send back a SOAP response with a graphic map in
> attachment spotting all the wifi hotspots 1000meters around the
> specified position. Maybe something like :
> 
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>    <soapenv:Body>
>        <html soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
>            <body>
>                <img src="map.gif"/>
>            </body>
>        </html>
>    </soapenv:Body>
> </soapenv:Envelope>
> 
> With map.gif in attachment of course.
> I know it's not very frequent as a usage of webservices but I need
> something like that.
> I hope it gives you a better idea of what I'm trying to achieve...
> 
> --
> Sebastien ARBOGAST
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon and Axis

Posted by Chris Holmes <ch...@gmail.com>.
If you're looking to do mapping stuff there is a whole body of
specifications, and open source implementations, to do exactly what
you want.  To get a map you can use the Web Map Service specification
- there is a Java implementation called GeoServer -
http://geoserver.sourceforge.net and a strong C implementation called
MapServer - http://mapserver.gis.umn.edu/  The specs are done by the
Open Geospatial Consortium - http://opengeospatial.org - and the WMS
one is quite mature, at the time they developed it SOAP was quite
young - they're making soap bindings for their web services now.  WMS
spec is here: http://portal.opengeospatial.org/files/?artifact_id=5316

Unfortunately there is no real good intro to the WMS spec, when I find
time I may just do one.  There is a not very good 'cookbook' here:
http://www.opengeospatial.org/resources/?page=cookbooks  And I'm happy
to answer any further questions on the geoserver lists.

A WMS will easily return maps as gifs, or other formats, and indeed
there are many clients that will allow you to zoom and navigate, and
to overlay the map you're requesting with maps from other WMS servers.
 You make requests generally with key value pairs in the url, or
through XML post requests.

(sorry for the random post without introducing myself - I'm mostly
lurking on the list for the discussion of micro kernel stuff - we're
thinking about many similar issues in the context of geoserver,
wanting a plug-in architecture for geospatial applications.)

best regards,

Chris

On 6/3/05, Sebastien Arbogast <se...@gmail.com> wrote:
> BTW I forgot to mention something. The purpose of my webservices is
> not to create some RPC interface to my business code. In fact I want
> to use the document style to generate XML documents using Cocoon
> sitemap facilities and feed them into my SOAP responses. And of course
> I want to use parameters I can extract from the SOAP request message
> body as parameters for the code that generates those documents. For
> example I receive this kind of SOAP request :
> 
> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
>    <SOAP-ENV:Header/>
>    <SOAP-ENV:Body>
>        <wifilist>
>            <location x="23.764578" y="87.875468" z=".7688"/>
>            <range radius="1000" unit="meters"/>
>        </wifilist>
>    </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
> 
> And I want to send back a SOAP response with a graphic map in
> attachment spotting all the wifi hotspots 1000meters around the
> specified position. Maybe something like :
> 
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>    <soapenv:Body>
>        <html soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
>            <body>
>                <img src="map.gif"/>
>            </body>
>        </html>
>    </soapenv:Body>
> </soapenv:Envelope>
> 
> With map.gif in attachment of course.
> I know it's not very frequent as a usage of webservices but I need
> something like that.
> I hope it gives you a better idea of what I'm trying to achieve...
> 
> --
> Sebastien ARBOGAST
>

Re: Cocoon and Axis

Posted by Sebastien Arbogast <se...@gmail.com>.
BTW I forgot to mention something. The purpose of my webservices is
not to create some RPC interface to my business code. In fact I want
to use the document style to generate XML documents using Cocoon
sitemap facilities and feed them into my SOAP responses. And of course
I want to use parameters I can extract from the SOAP request message
body as parameters for the code that generates those documents. For
example I receive this kind of SOAP request :

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
       <wifilist>
           <location x="23.764578" y="87.875468" z=".7688"/>
           <range radius="1000" unit="meters"/>
       </wifilist>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

And I want to send back a SOAP response with a graphic map in
attachment spotting all the wifi hotspots 1000meters around the
specified position. Maybe something like :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soapenv:Body>
       <html soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
           <body>
               <img src="map.gif"/>
           </body>
       </html>
   </soapenv:Body>
</soapenv:Envelope>

With map.gif in attachment of course.
I know it's not very frequent as a usage of webservices but I need
something like that.
I hope it gives you a better idea of what I'm trying to achieve...

--
Sebastien ARBOGAST

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon and Axis

Posted by Sebastien Arbogast <se...@gmail.com>.
> Sebastien,
>
> Can you please explain a bit what you are trying to achieve? (use
> case?). Do you need to use Axis handlers? Where is your business logic
> going to reside (java objects? ejb?)

Alright. My Cocoon application is based on a Spring business logic and
I'm using Flowscript as a controller language.
What I want to achieve is quite simple in fact. My application can
receive traditional http requests (for back-office administration) or
SOAP webservice requests (let's say over HTTP for now) for services.
Jan Hinzman came up with an interesting approach to get the SOAP
envelope out the the request using Cocoon sitemap and a
StreamGenerator. But then he uses a JXTemplate and some XSLT
stylesheets to extract information from the SOAP envelope he has
stored in a ByteArrayOutputStream, and then to rebuild a SOAP answer
to send back. It works for his small sample with an echo webservice,
but I intend to use more complex features of SOAP, including
attachments.
I'm reading the excellent "Building Web services with Java" and in the
chapter about "Implementing Web Services with Apache Axis" they say
that :

"When you use Axis as a SOAP server, the first thing that happens is
that a transport listener receives a message. Transport listener is a
fancy term for any software that can take input and turn it into
something that Axis understand. For example this might be a
servlet..."

And I thought it would be great if it could be some Cocoon component.
So more concretely here is the use case :
1- a user sends a SOAP request to this address :
http://localhost:8080/myapp/modules/echo.ws
2- I have a sitemap pipeline matching that request in
http://localhost:8080/myapp/modules/sitemap.xmap

           <map:match pattern="*.ws">
               <map:call function="webservice">
                   <map:parameter name="module" value="{1}"/>
               </map:call>
           </map:match>

3- In the "webservice" flowscript function there are two possible subcases :
3.1 - Either I manage to get or build a org.apache.axis.MessageContext
object from the request that lead me there and it's great because I
can use all the Axis handler facilities and combine flowscript and my
Spring business layer to provide the service and build the response
3.2 - Or it's not possible and at least I'd like to use Axis Message
API to manipulate my SOAP envelope instead of fiddling something dirty
with JXT/XSLT. If I have to do that, I'm looking for a way to build a
org.apache.axis.Message from the ByteArrayOutputStream I get in
soapEnvelope variable thanks to this flowscript code :

var soapEnvelope = new java.io.ByteArrayOutputStream();
cocoon.processPipelineTo("soapEnvelope", null, soapEnvelope);

And this sitemap pattern :

           <map:match pattern="soapEnvelope">
               <map:generate type="stream"/>
               <map:serialize type="xmlnope"/>
           </map:match>

The thing is I'm just learning to use Axis (I'm currently finishing to
read this chapter about it) and I don't know Cocoon architecture
enough to know what is possible or not here. You may say "then RTFM
and come back later" but I only have 2 days to come up with a working
prototype of my system and this is the last part of it so... I was
thinking I could speed it up thanks to your more pragmatic approach.
Anyway, if you need any precision, feel free to ask.

--
Sébastien Arbogast

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon and Axis

Posted by Sebastien Arbogast <se...@gmail.com>.
> Sebastien,
>
> Can you please explain a bit what you are trying to achieve? (use
> case?). Do you need to use Axis handlers? Where is your business logic
> going to reside (java objects? ejb?)

Alright. My Cocoon application is based on a Spring business logic and
I'm using Flowscript as a controller language.
What I want to achieve is quite simple in fact. My application can
receive traditional http requests (for back-office administration) or
SOAP webservice requests (let's say over HTTP for now) for services.
Jan Hinzman came up with an interesting approach to get the SOAP
envelope out the the request using Cocoon sitemap and a
StreamGenerator. But then he uses a JXTemplate and some XSLT
stylesheets to extract information from the SOAP envelope he has
stored in a ByteArrayOutputStream, and then to rebuild a SOAP answer
to send back. It works for his small sample with an echo webservice,
but I intend to use more complex features of SOAP, including
attachments.
I'm reading the excellent "Building Web services with Java" and in the
chapter about "Implementing Web Services with Apache Axis" they say
that :

"When you use Axis as a SOAP server, the first thing that happens is
that a transport listener receives a message. Transport listener is a
fancy term for any software that can take input and turn it into
something that Axis understand. For example this might be a
servlet..."

And I thought it would be great if it could be some Cocoon component.
So more concretely here is the use case :
1- a user sends a SOAP request to this address :
http://localhost:8080/myapp/modules/echo.ws
2- I have a sitemap pipeline matching that request in
http://localhost:8080/myapp/modules/sitemap.xmap

           <map:match pattern="*.ws">
               <map:call function="webservice">
                   <map:parameter name="module" value="{1}"/>
               </map:call>
           </map:match>

3- In the "webservice" flowscript function there are two possible subcases :
3.1 - Either I manage to get or build a org.apache.axis.MessageContext
object from the request that lead me there and it's great because I
can use all the Axis handler facilities and combine flowscript and my
Spring business layer to provide the service and build the response
3.2 - Or it's not possible and at least I'd like to use Axis Message
API to manipulate my SOAP envelope instead of fiddling something dirty
with JXT/XSLT. If I have to do that, I'm looking for a way to build a
org.apache.axis.Message from the ByteArrayOutputStream I get in
soapEnvelope variable thanks to this flowscript code :

var soapEnvelope = new java.io.ByteArrayOutputStream();
cocoon.processPipelineTo("soapEnvelope", null, soapEnvelope);

And this sitemap pattern :

           <map:match pattern="soapEnvelope">
               <map:generate type="stream"/>
               <map:serialize type="xmlnope"/>
           </map:match>

The thing is I'm just learning to use Axis (I'm currently finishing to
read this chapter about it) and I don't know Cocoon architecture
enough to know what is possible or not here. You may say "then RTFM
and come back later" but I only have 2 days to come up with a working
prototype of my system and this is the last part of it so... I was
thinking I could speed it up thanks to your more pragmatic approach.
Anyway, if you need any precision, feel free to ask.

--
Sébastien Arbogast

Re: Cocoon and Axis

Posted by Sebastien Arbogast <se...@gmail.com>.
BTW I forgot to mention something. The purpose of my webservices is
not to create some RPC interface to my business code. In fact I want
to use the document style to generate XML documents using Cocoon
sitemap facilities and feed them into my SOAP responses. And of course
I want to use parameters I can extract from the SOAP request message
body as parameters for the code that generates those documents. For
example I receive this kind of SOAP request :

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
       <wifilist>
           <location x="23.764578" y="87.875468" z=".7688"/>
           <range radius="1000" unit="meters"/>
       </wifilist>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

And I want to send back a SOAP response with a graphic map in
attachment spotting all the wifi hotspots 1000meters around the
specified position. Maybe something like :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soapenv:Body>
       <html soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
           <body>
               <img src="map.gif"/>
           </body>
       </html>
   </soapenv:Body>
</soapenv:Envelope>

With map.gif in attachment of course.
I know it's not very frequent as a usage of webservices but I need
something like that.
I hope it gives you a better idea of what I'm trying to achieve...

--
Sebastien ARBOGAST

Re: Cocoon and Axis

Posted by Davanum Srinivas <da...@gmail.com>.
Sebastien,

Can you please explain a bit what you are trying to achieve? (use
case?). Do you need to use Axis handlers? Where is your business logic
going to reside (java objects? ejb?)

thanks,
dims
(Cocoon Emeritus & Axis Committer)

On 6/3/05, Sebastien Arbogast <se...@gmail.com> wrote:
> Hi there,
> 
> I'm trying to find a clean alternative to use Cocoon as a webservice
> server using Axis as a library. So I see two solutions right now :
> 1 - using Jan's approach with a StreamGenerator
> (http://wiki.apache.org/cocoon/WebServiceServer) to get the SOAP
> message in a ByteArrayOutputStream and then use that to build an Axis
> message I can manipulate from flowscript
> 2 - or even better, it would be great if I could use Cocoon servlet as
> an HTTP listener (equivalent to the Axis servlet) to get directly a
> Message Context somewhere.
> 
> Does anybody have an idea of how I can integrate Axis inside Cocoon ?
> 
> And I found that
> (http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/components/axis/SoapServer.html)
> in the API docs... would it be useful ? how ?
> 
> Thx in advance.
> 
> --
> Sebastien ARBOGAST
> 


-- 
Davanum Srinivas - http://webservices.apache.org/~dims/

Re: Cocoon and Axis

Posted by Davanum Srinivas <da...@gmail.com>.
Sebastien,

Can you please explain a bit what you are trying to achieve? (use
case?). Do you need to use Axis handlers? Where is your business logic
going to reside (java objects? ejb?)

thanks,
dims
(Cocoon Emeritus & Axis Committer)

On 6/3/05, Sebastien Arbogast <se...@gmail.com> wrote:
> Hi there,
> 
> I'm trying to find a clean alternative to use Cocoon as a webservice
> server using Axis as a library. So I see two solutions right now :
> 1 - using Jan's approach with a StreamGenerator
> (http://wiki.apache.org/cocoon/WebServiceServer) to get the SOAP
> message in a ByteArrayOutputStream and then use that to build an Axis
> message I can manipulate from flowscript
> 2 - or even better, it would be great if I could use Cocoon servlet as
> an HTTP listener (equivalent to the Axis servlet) to get directly a
> Message Context somewhere.
> 
> Does anybody have an idea of how I can integrate Axis inside Cocoon ?
> 
> And I found that
> (http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/components/axis/SoapServer.html)
> in the API docs... would it be useful ? how ?
> 
> Thx in advance.
> 
> --
> Sebastien ARBOGAST
> 


-- 
Davanum Srinivas - http://webservices.apache.org/~dims/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org