An approach I have used, to SOAPafy my Cocoon actions is to work with the SOAP Message format, not RPC, and then ignore the SOAP wrapper tags. Let me explain by example:

I have a method which runs a database search based on a keyword passed in by the user.

I define a simple XML wrapper for the keyword:
  <searchIt>foo</searchIt>


I have a SOAP client send the request in the body of the SOAP request, so the request looks like:


<SOAP-ENV:Envelope ...>
   <SOAP-ENV:Header>...</SOAP-ENV:Header>
   <SOAP-ENV:Body>
   <searchIt>foo</searchIt>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


I send this request, through HTTP to a normal Cocoon endpoint, with a matcher firing off of the URL I give it.



The pipeline for the request looks like:

<map:match pattern="searchItReq">
<!-- us the stream generator to just flow the SOAP request -->
<!-- as is into the pipeline -->
<map:generate type="stream"/>


<!-- use a style sheet with a template to match the "searchIt" tag, produce the -->
<!-- the XML for the next action. It is very important that this stylesheet passes -->
<!-- unrecognized tags, as is, through the it (see below for the xslt for that) -->
<map:transform type="xslt" src="searchManagement.xslt"/>


<!-- this is a call to another pipeline, which build an actual SQL statement with a XSTL, -->
<!-- passes that to the SQLTransformer (see Cocoon' website) Still, any XSLT -->
<!-- transformer passes unrecognized XML tags though. -->
<map:call resource="pipe-searchSQL"/>


<!-- this XSLT expects the SQL response as formatted by the SQLTransformer output -->
<!-- and builds the expect response. Again, all the transformer passes unrecognized -->
<!-- XML tags though. When building the response, it stills ignore any SOAP tag, -->
<!-- it just resplaces tags tied the searchIt or SQL response -->
<map:transform type="xslt" src="searchGroup.xslt"/>


       <!-- send XML back  -->
      <map:serialize type="xml"/>
   </map:match>


The response returned to the SOAP client would be: <SOAP-ENV:Envelope ...> <SOAP-ENV:Header>...</SOAP-ENV:Header> <SOAP-ENV:Body> <yourResults>bar</yourResults> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

All the SOAP-ENV tags are passed unmodified from the request's SOAP-ENV tags.



The good of this approach:
It is pretty easy to tweak your response, as most of it is done in XSTL.
If your not a AXIS expert, you can add still add lots of functionality through plain Cocoon.



The bad:
You lose many of SOAP's data type checking. Calls to RPC methods will require more work to mimic in Cocoon.
I had to write my own reader to place in the <map:handle-errors> catch, to properly format Cocoon messages into SOAP response.
Generating an WSDL is a manual exercise.




The ugly:
Pure SOAP snobs will not like it.
It leads to many smaller stylesheets.


Alternatives?
For Attachment handling, existing SOAP services, I took the AXISRPC... stuff as a base, and built a generator which calls the AXIS engine to process the request (Clue: .wsdd goes in your WEB-INF/class/.. directory) and spew the resulting XML into an XML pipeline, so I can post process it, if needed. Sorry , as it stands I can not contribute this code, due to my company current or lack of policy.



I hope this helps, "Building Web Services with Java" by Steve Graham, ... was a good source of information on the guts of a SOAP message.




As mentioned above the XSLT to pass tags unmolested is:
 <xsl:template match="@*|node()">
   <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
   </xsl:copy>
 </xsl:template>


Later, Scott Schwab

-- these comments are my personal comments and may or may not represent my employer's view --




Robert Simmons Jr. wrote:

I was looking for examples of how to make my applications SOAP available. I have a web app for people to set up their subscriptions to information wires. But I would like them to be able to access this via their PDA using SOAP.

Can someone point me in the right direction?


-- Regards -- Robert Simmons Jr.

Author: Hardcore Java, Published March 2004 by O'Reilly
http://www.oreilly.com/catalog/hardcorejv/





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]








---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to