Ok, sorry that it took me a little bit longer but I�m currently busy.
Here is the first of the promised Soap postings on how to merge Jetspeed
and Axis.
Attached you can find my web.xml file I currently use on my merged
system. Note that it works more or less but it still needs a little bit
of fixing maybe (I was just eager to get the thing up and running)
Also here is a little example of a simple Soap Portlet which accesses
a remote jokes database somehwere on the net (you don�t have to mind
sexist and dirty jokes though, but
it is an excellent example due to its simplicity, I found it on the net
so please don�t hammer this server, I don�t know whom it belongs to.
It�s public but...)
The WSDL file is:
---
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:s0="http://interpressfact.net/webservices/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://interpressfact.net/webservices/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<s:schema elementFormDefault="qualified"
targetNamespace="http://interpressfact.net/webservices/">
<s:element name="getJoke">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Category"
type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="getJokeResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="getJokeResult"
type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="string" nillable="true" type="s:string" />
</s:schema>
</types>
<message name="getJokeSoapIn">
<part name="parameters" element="s0:getJoke" />
</message>
<message name="getJokeSoapOut">
<part name="parameters" element="s0:getJokeResponse" />
</message>
<message name="getJokeHttpGetIn">
<part name="Category" type="s:string" />
</message>
<message name="getJokeHttpGetOut">
<part name="Body" element="s0:string" />
</message>
<message name="getJokeHttpPostIn">
<part name="Category" type="s:string" />
</message>
<message name="getJokeHttpPostOut">
<part name="Body" element="s0:string" />
</message>
<portType name="getJokeSoap">
<operation name="getJoke">
<documentation>Joke categories:<br><br>Murphy's Laws
- 7<br>Q&A - 3<br>Unnatural Laws - 18<br>Cool
Jokes - 6<br>Blondes - 2<br>Random(contains Adult) -
1<br>Lawyers - 5<br>Headlines - 8<br>Military -
9<br>All categories - 0<br><br></documentation>
<input message="s0:getJokeSoapIn" />
<output message="s0:getJokeSoapOut" />
</operation>
</portType>
<portType name="getJokeHttpGet">
<operation name="getJoke">
<documentation>Joke categories:<br><br>Murphy's Laws
- 7<br>Q&A - 3<br>Unnatural Laws - 18<br>Cool
Jokes - 6<br>Blondes - 2<br>Random(contains Adult) -
1<br>Lawyers - 5<br>Headlines - 8<br>Military -
9<br>All categories - 0<br><br></documentation>
<input message="s0:getJokeHttpGetIn" />
<output message="s0:getJokeHttpGetOut" />
</operation>
</portType>
<portType name="getJokeHttpPost">
<operation name="getJoke">
<documentation>Joke categories:<br><br>Murphy's Laws
- 7<br>Q&A - 3<br>Unnatural Laws - 18<br>Cool
Jokes - 6<br>Blondes - 2<br>Random(contains Adult) -
1<br>Lawyers - 5<br>Headlines - 8<br>Military -
9<br>All categories - 0<br><br></documentation>
<input message="s0:getJokeHttpPostIn" />
<output message="s0:getJokeHttpPostOut" />
</operation>
</portType>
<binding name="getJokeSoap" type="s0:getJokeSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
<operation name="getJoke">
<soap:operation
soapAction="http://interpressfact.net/webservices/getJoke"
style="document" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
<binding name="getJokeHttpGet" type="s0:getJokeHttpGet">
<http:binding verb="GET" />
<operation name="getJoke">
<http:operation location="/getJoke" />
<input>
<http:urlEncoded />
</input>
<output>
<mime:mimeXml part="Body" />
</output>
</operation>
</binding>
<binding name="getJokeHttpPost" type="s0:getJokeHttpPost">
<http:binding verb="POST" />
<operation name="getJoke">
<http:operation location="/getJoke" />
<input>
<mime:content type="application/x-www-form-urlencoded" />
</input>
<output>
<mime:mimeXml part="Body" />
</output>
</operation>
</binding>
<service name="getJoke">
<documentation><a href='http://interpressfact.net'><img
src='http://www.interpressfact.net/webpage.files/logo.gif'
border='0'></a><br><font color='#006600' size='3'
face='Geneva, Arial, Helvetica, san-serif'>Returns random joke every
time this webservice is invoked.</font></documentation>
<port name="getJokeSoap" binding="s0:getJokeSoap">
<soap:address
location="http://www.interpressfact.net/webservices/getJoke.asmx" />
</port>
<port name="getJokeHttpGet" binding="s0:getJokeHttpGet">
<http:address
location="http://www.interpressfact.net/webservices/getJoke.asmx" />
</port>
<port name="getJokeHttpPost" binding="s0:getJokeHttpPost">
<http:address
location="http://www.interpressfact.net/webservices/getJoke.asmx" />
</port>
</service>
</definitions>
---
The Portlet doPerform code is:
public void doPerform(RunData data, Context context) {
try {
GetJoke_ServiceLocator locator = new GetJoke_ServiceLocator();
GetJokeSoap stub = (GetJokeSoap) locator.getgetJokeSoap();
context.put("CURRENT_JOKE",stub.getJoke("2"));
} catch (Exception ex) {
//do whatever error handling you like
}
}
For all of you not familiar with Axis, here is a short explanation since
The data I�ve sent with this mail is rather minimalistic:
the GetJoke_ServiceLocator
and GetJokeSoap Objects are so called stub objects which
access the remote server those objects are generated with
a compiler which comes with axis (wsdl2java). I personally
use a hava ant task to generate the stub objects.
I think you might get the clue how awesome the combination axis and
Jetspeed is. Also the other path is possible this way. Thanks
to the shared webapp, you can serve Soap Services directly from a
Jetspeed installation. I did a simply testwebservices which serves
me banner data which is used on my local jetspeed installation.
(Here is a code snip of a theoretical banner service)
public class BannerSoapService {
public List getBannerDataAsList(String foobaz) {
LinkedList retData = new LinkedList();
retData.add("http://xxx.banner.yyy");
retData.add("mybanner.gif");
return retData;
}
}
This soap service (if properly deployed either as jws file or via
a WSDD file)
delivers back banner data. Note that currently
it only is statically coded, but you theoretically could fetch
the data from a local database and serve it back. Thanks
to the shared install all the config files and classes
of the local jetspeed installation and the delivered soap services are
shared.
A client without stubs for getting the banner would look like this
(snipped from a local testcase I run):
String endpoint =
"http://localhost:8080/jetspeed/jws/banner/Banner.jws";
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName( "getBannerDataAsList" );
call.addParameter( "op1", XMLType.XSD_STRING,
ParameterMode.IN );
call.setReturnType(XMLType.XSD_ANY,java.util.List.class);
java.util.List helloList = (java.util.List) call.invoke(new
Object[] {"foobaz"});
As for merging Axis and Jetspeed I already gave an explanation in this
list. Maybe I will do an ANT build file next week (depending on my
schedule) which merges the binaries of Jetspeed 1.4b1 and Axis
automatically, which I know it can be done.
As for other questions. I will try to help in this thread as much as
possible and also have a look at the axis homepage at xml.apache.org.
Although the docs are rather beta (not too much documentation there on
various issues) they give a good start into Soap.
That sums it up so far. I will try to answer the arising questions
(note that I�m neither one of the Axis nor of the Jetspeed developers)
as much as possible and maybe if I have time I will make a build
file which should automate the merging process, which I describe in an
earlier mail.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<display-name>Apache-Axis</display-name>
<servlet>
<servlet-name>
jetspeed
</servlet-name>
<servlet-class>
org.apache.turbine.Turbine
</servlet-class>
<init-param>
<param-name>properties</param-name>
<param-value>
WEB-INF/conf/TurbineResources.properties
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>AxisServlet</servlet-name>
<display-name>Apache-Axis Servlet</display-name>
<servlet-class>
org.apache.axis.transport.http.AxisServlet
</servlet-class>
</servlet>
<servlet>
<servlet-name>AdminServlet</servlet-name>
<display-name>Axis Admin Servlet</display-name>
<servlet-class>
org.apache.axis.transport.http.AdminServlet
</servlet-class>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet>
<servlet-name>SOAPMonitorService</servlet-name>
<display-name>SOAPMonitorService</display-name>
<servlet-class>
org.apache.axis.monitor.SOAPMonitorService
</servlet-class>
<init-param>
<param-name>SOAPMonitorPort</param-name>
<param-value>5001</param-value>
</init-param>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/servlet/AxisServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>*.jws</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SOAPMonitorService</servlet-name>
<url-pattern>/SOAPMonitor</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>
jetspeed
</servlet-name>
<url-pattern>
/portal/*
</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>
jetspeed
</servlet-name>
<url-pattern>
/jetspeed/*
</url-pattern>
</servlet-mapping>
<mime-mapping>
<extension>wbmp</extension>
<mime-type>image/vnd.wap.wbmp</mime-type>
</mime-mapping>
<mime-mapping>
<extension>wml</extension>
<mime-type>text/vnd.wap.wml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>wmls</extension>
<mime-type>text/vnd.wap.wmlscript</mime-type>
</mime-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.wml</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>