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/05/28 00:28:13 UTC

Cocon and WebServices

Hi,

I'm considering the possibility to integrate Web Services around my
application (which uses a CHS architecture). For the moment my
priority is to expose web services but later I'll probably need to
consume some too.
To expose Cocoon via SOAP I heard of two possible approaches :
- the one introduced by Jan Hinzman in this recent Wiki article :
http://wiki.apache.org/cocoon/WebServiceServer
- and the use of Axis block as illustrated in the samples

What's the difference between both approaches and where should I look
for information to make it as elegantly as possible ?

Thx in advance
Regards
-- 
Sebastien ARBOGAST

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


Re: Cocon and WebServices

Posted by Jan Hinzmann <ja...@geeksonly.de>.
Hi Sebastien,

I put up a diagram on my webspace, maybe it helps you a little bit to get 
through my code.
You can find it here:
http://jan.geeksonly.de/cocoon/images/Sequence_Diagram__seq_webservice.png

On Wednesday 01 June 2005 20:26, Sebastien Arbogast wrote:
> Now I'm not sorry anymore ! I'm ashamed !!! I found the bug in my
> sitemap, I had not declared the new serializer correctly. Thank you
> very much Jan. Really !
> 
> -- 
> Sebastien ARBOGAST
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 

-- 
Gruß, Jan

Re: Cocon and WebServices

Posted by Dennis Riedel <de...@web.de>.
Hello
Can Cocoon with Axis work as WebService Provider. I mean can it (as 
avalon component or s.th.) get request and send response to a client?
Looking on server client aspects: can cocoon (a component of it) serve 
as a RMI Server and handle requests?



Jan Hinzmann wrote:

>Hi Sebastien,
>
>in my application the use of axis doubled my code. That is, I had to write the 
>same code in my flowscript and in another javaclass.
>
>To answer your question: No, I did not use axis as a library.
>
>But that would be interesting, e.g. for generating a wsdl-file.
>
>
>On Thursday 02 June 2005 21:06, Sebastien Arbogast wrote:
>  
>
>>2005/6/2, Jan Hinzmann <ja...@geeksonly.de>:
>>    
>>
>>>:o)
>>>I'm happy, that I have infected you with the cocoon-webservice-virus and 
>>>      
>>>
>that
>  
>
>>>now there is someone out there, who can potentially help me, wehen I get 
>>>      
>>>
>in
>  
>
>>>trouble.
>>>      
>>>
>>:-) Just one small question. Have you tried to use Axis as a library
>>(not the cocoon block) from flowscript ? I don't know Axis very well
>>but I can't believe it's not possible to use it to do what you did
>>using JXTemplates and XSLT. Because the problem with your approach is
>>that we can only use a very small part of SOAP capacities.
>>I'd just like to know if you've searched that way, to know whether
>>it's worth having a look.
>>
>>-- 
>>Sebastien ARBOGAST
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>>    
>>
>
>  
>


Re: Cocon and WebServices

Posted by Jan Hinzmann <ja...@geeksonly.de>.
Hi Sebastien,

in my application the use of axis doubled my code. That is, I had to write the 
same code in my flowscript and in another javaclass.

To answer your question: No, I did not use axis as a library.

But that would be interesting, e.g. for generating a wsdl-file.


On Thursday 02 June 2005 21:06, Sebastien Arbogast wrote:
> 2005/6/2, Jan Hinzmann <ja...@geeksonly.de>:
> > :o)
> > I'm happy, that I have infected you with the cocoon-webservice-virus and 
that
> > now there is someone out there, who can potentially help me, wehen I get 
in
> > trouble.
> 
> :-) Just one small question. Have you tried to use Axis as a library
> (not the cocoon block) from flowscript ? I don't know Axis very well
> but I can't believe it's not possible to use it to do what you did
> using JXTemplates and XSLT. Because the problem with your approach is
> that we can only use a very small part of SOAP capacities.
> I'd just like to know if you've searched that way, to know whether
> it's worth having a look.
> 
> -- 
> Sebastien ARBOGAST
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 

-- 
Gruß, Jan

Re: Cocon and WebServices

Posted by Sebastien Arbogast <se...@gmail.com>.
2005/6/2, Jan Hinzmann <ja...@geeksonly.de>:
> :o)
> I'm happy, that I have infected you with the cocoon-webservice-virus and that
> now there is someone out there, who can potentially help me, wehen I get in
> trouble.

:-) Just one small question. Have you tried to use Axis as a library
(not the cocoon block) from flowscript ? I don't know Axis very well
but I can't believe it's not possible to use it to do what you did
using JXTemplates and XSLT. Because the problem with your approach is
that we can only use a very small part of SOAP capacities.
I'd just like to know if you've searched that way, to know whether
it's worth having a look.

-- 
Sebastien ARBOGAST

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


Re: Cocon and WebServices

Posted by Jan Hinzmann <ja...@geeksonly.de>.
:o)
I'm happy, that I have infected you with the cocoon-webservice-virus and that 
now there is someone out there, who can potentially help me, wehen I get in 
trouble.

On Wednesday 01 June 2005 20:26, Sebastien Arbogast wrote:
> Now I'm not sorry anymore ! I'm ashamed !!! I found the bug in my
> sitemap, I had not declared the new serializer correctly. Thank you
> very much Jan. Really !
> 
> -- 
> Sebastien ARBOGAST
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 

-- 
Gruß, Jan

Re: Cocon and WebServices

Posted by Sebastien Arbogast <se...@gmail.com>.
Now I'm not sorry anymore ! I'm ashamed !!! I found the bug in my
sitemap, I had not declared the new serializer correctly. Thank you
very much Jan. Really !

-- 
Sebastien ARBOGAST

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


Re: Cocon and WebServices

Posted by Sebastien Arbogast <se...@gmail.com>.
> Hi Sebastien,
> 
> :D thanks for your faith!
> 
> If I find some time, I'll surely will write a little more in the wiki.
> At the moment I have to do lot of work for my studies ...

I know exactly what you mean because if I need that information it's
for a project in my studies too :-P

> ... but  I tried to explain the way, I managed to do a webservice in this
> mail.
> I also hacked a little example and attached it to the wikipage
> 
> http://wiki.apache.org/cocoon/WebServiceServer

I just tried to test your sample (thank you very much for the time you
spared on it !) and I don't manage to test it. I tried to write a
simple WSDL file to test the service from OxygenXML using the WSDL
Soap Analyzer but when I try to invoke the service I always get the
same error :

[quote]
com.sun.xml.messaging.saaj.SOAPExceptionImpl: Invalid
Content-Type:text/html. Is this an error message instead of a SOAP
response?
[/quote]

How did you test your webservice ? Because I'd like to make sure it
works in my context before I try to understand how it works and how I
can adapt it.
 
> I hope this helps. I would write more and better, but  the time .... ;)
> have to wait, because i have to leave for now :(

I'm really sorry to bother you with that because I would hate myself
if I were you ;-)

But if anybody managed to get Jan's approach up and running I could
really use some help.
(aaarrrrgh only 2 weeks left ! ;-))

-- 
Sebastien ARBOGAST

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


Re: Cocon and WebServices

Posted by Jan Hinzmann <ja...@geeksonly.de>.
Hi Sebastien,

:D thanks for your faith!

If I find some time, I'll surely will write a little more in the wiki.
At the moment I have to do lot of work for my studies ...


... but  I tried to explain the way, I managed to do a webservice in this 
mail. 
I also hacked a little example and attached it to the wikipage 

http://wiki.apache.org/cocoon/WebServiceServer


Anyway, in basic you'll have to do something like:

1. receive the SOAP-request
2. extract the methodname, which is called and then
    extract eventually methodparameters
3. process some computation
4. generate and send SOAP-Answer back to the client

1. receiving a SOAP-request
1.1 You'll have to match the request in the sitemap and call your flowscript.
1.2 In the flowscript you generate the SOAP-Envelope using a sitemap-matcher 
      with a StreamGenerator. And serialize it without the XML-Declaration 
     (configure a XMLSerializer with 
     <omit-xml-declaration>yes</omit-xml-declaration>)
1.3 You then store the SOAP-Envelope in a variable for latter use

Now you have the XML-File which was sent by the client.
You have now to learn, which Method the client is calling:

2. Extracting the Method out of the SOAP-Envelope
2.1 The name of the Node, which follows the <soapenv:Body>-node, is the 
      method-name (typically something like <ns1:methodname ...>).
2.2 To generate the SOAP-Envelope in the sitemap, you need the JXTemplate with 
      the method 'stringToSAX' described in the wiki 
      (http://wiki.apache.org/cocoon/WebServiceServer)
2.3 You then transform the Envelope with a stylesheet, that extracts the 
      methodname ... see soapMethod.xsl
2.4 Store this String in a variable and build an if-cascade over the possible 
methods
2.5 if no if-statement matches, you should generate a soap-fault

Now you are almost done.
You have the methodname and the parameters, so you'll know what to do.

3.1 do the work for your method

Now it's time to generate the answer. This can be a SOAP-Fault with an 
exceptionmessage in it or some String describing the answer, a 
XML-Document, ...

4.1 in the flowscript use the cocoon.sendPage(...) method to send back the 
answer
4.2 in the sitemap generate a dummy.xml and
4.3 transform it with a soapAnswer.xsl. this is where the SOAP-Envelope is 
stored. You have to pass your answer as parameter to the transformation.
4.4 serialize the answer as xml to the client.

5. done

I hope this helps. I would write more and better, but  the time .... ;)


have to wait, because i have to leave for now :(

On Wednesday 01 June 2005 06:42, Sebastien Arbogast wrote:
> 2005/5/31, Jan Hinzmann <ja...@geeksonly.de>:
> > The Axisblock doubled my code, so I came up with a
> > "plain-cocoon-soap-webservice"
> > 
> > The Axis-Block is just a kind of Proxy.
> > 
> > Sorry for the short answer.
> 
> Actually I could really use a more detailed answer if you had time
> because I really need to figure out how to expose webservices through
> Cocoon and I don't manage to understand your article on the Wiki.
> Would it be possible for you to write a small sample, a very simple
> Cocoon application that just exposes your echo webservice so that one
> can just test it through XMLSpy SOAP request for example, and then
> build something more sophisticated on top of that.
> I know it can represent a bit of work for you but as you seem to be
> the most advanced on this subject, I can do nothing but to place all
> my faith in you ;-)
> 
> Thx in advance.
> Cheers.
> -- 
> Sebastien ARBOGAST
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 

-- 
Gruß, Jan

Re: Cocon and WebServices

Posted by Sebastien Arbogast <se...@gmail.com>.
2005/5/31, Jan Hinzmann <ja...@geeksonly.de>:
> The Axisblock doubled my code, so I came up with a
> "plain-cocoon-soap-webservice"
> 
> The Axis-Block is just a kind of Proxy.
> 
> Sorry for the short answer.

Actually I could really use a more detailed answer if you had time
because I really need to figure out how to expose webservices through
Cocoon and I don't manage to understand your article on the Wiki.
Would it be possible for you to write a small sample, a very simple
Cocoon application that just exposes your echo webservice so that one
can just test it through XMLSpy SOAP request for example, and then
build something more sophisticated on top of that.
I know it can represent a bit of work for you but as you seem to be
the most advanced on this subject, I can do nothing but to place all
my faith in you ;-)

Thx in advance.
Cheers.
-- 
Sebastien ARBOGAST

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


Re: Cocon and WebServices

Posted by Jan Hinzmann <ja...@geeksonly.de>.
The Axisblock doubled my code, so I came up with a 
"plain-cocoon-soap-webservice"

The Axis-Block is just a kind of Proxy.


Sorry for the short answer.

On Saturday 28 May 2005 00:28, Sebastien Arbogast wrote:
> Hi,
> 
> I'm considering the possibility to integrate Web Services around my
> application (which uses a CHS architecture). For the moment my
> priority is to expose web services but later I'll probably need to
> consume some too.
> To expose Cocoon via SOAP I heard of two possible approaches :
> - the one introduced by Jan Hinzman in this recent Wiki article :
> http://wiki.apache.org/cocoon/WebServiceServer
> - and the use of Axis block as illustrated in the samples
> 
> What's the difference between both approaches and where should I look
> for information to make it as elegantly as possible ?
> 
> Thx in advance
> Regards
> -- 
> Sebastien ARBOGAST
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 

-- 
Gruß, Jan