...
Code Block |
---|
|
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis-jaxrpc</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis-saaj</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>axis</groupId>
<artifactId>axis-wsdl4j</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<version>0.4</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
|
...
Code Block |
---|
|
<!-- to compile with 1.5 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<configuration>
<sourceDirectory>src/main/resources/</sourceDirectory>
<packageSpace>com.mycompany.myschema</packageSpace>
<testCases>false</testCases>
<serverSide>true</serverSide>
<subPackageByFileName>false</subPackageByFileName>
</configuration>
<executions>
<execution>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
|
...
Code Block |
---|
|
<servlet>
<servlet-name>axis</servlet-name>
<servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>axis</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
|
The web.xml just configures Axisregisteres AXIS servlet that is handling the incoming web requests to its servlet mapping. We still need to configure AXIS itself and this is done using its special configuration file server-config.wsdd
. We nearly get this file for free if we let Axis generate the source code so we run the maven goal:
Code Block |
---|
mvn axistools:wsdl2java
|
The tool will generate the source code based on the wsdl and save the files to the following folder:
Code Block |
---|
.\target\generated-sources\axistools\wsdl2java\org\apache\camel\example\reportincident
deploy.wsdd
InputReportIncident.java
OutputReportIncident.java
ReportIncidentBindingImpl.java
ReportIncidentBindingStub.java
ReportIncidentService_PortType.java
ReportIncidentService_Service.java
ReportIncidentService_ServiceLocator.java
undeploy.wsdd
|
This is standard AXIS and so far no Camel or Spring has been touched. To implement our webservice we will add our code, so we create a new class AxisReportIncidentService
that implements the port type interface where we can implement our code logic what happens when the webservice is invoked.
Code Block |
---|
|
package org.apache.camel.example.axis;
import org.apache.camel.example.reportincident.InputReportIncident;
import org.apache.camel.example.reportincident.OutputReportIncident;
import org.apache.camel.example.reportincident.ReportIncidentService_PortType;
import java.rmi.RemoteException;
/**
* Axis webservice
*/
public class AxisReportIncidentService implements ReportIncidentService_PortType {
public OutputReportIncident reportIncident(InputReportIncident parameters) throws RemoteException {
System.out.println("Hello AxisReportIncidentService is called from " + parameters.getGivenName());
OutputReportIncident out = new OutputReportIncident();
out.setCode("OK");
return out;
}
}
|
Now we need to configure AXIS itself and this is done using its server-config.wsdd
file. We nearly get this for for free from the auto generated code, we copy the stuff from deploy.wsdd
and made a few modifications:
Code Block |
---|
|
<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<!-- global configuration -->
<globalConfiguration>
<parameter name="sendXsiTypes" value="true"/>
<parameter name="sendMultiRefs" value="true"/>
<parameter name="sendXMLDeclaration" value="true"/>
<parameter name="axis.sendMinimizedElements" value="true"/>
</globalConfiguration>
<handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper"/>
<!-- this service is from deploy.wsdd -->
<service name="ReportIncidentPort" provider="java:RPC" style="document" use="literal">
<parameter name="wsdlTargetNamespace" value="http://reportincident.example.camel.apache.org"/>
<parameter name="wsdlServiceElement" value="ReportIncidentService"/>
<parameter name="schemaUnqualified" value="http://reportincident.example.camel.apache.org"/>
<parameter name="wsdlServicePort" value="ReportIncidentPort"/>
<parameter name="className" value="org.apache.camel.example.reportincident.ReportIncidentBindingImpl"/>
<parameter name="wsdlPortType" value="ReportIncidentService"/>
<parameter name="typeMappingVersion" value="1.2"/>
<operation name="reportIncident" qname="ReportIncident" returnQName="retNS:outputReportIncident" xmlns:retNS="http://reportincident.example.camel.apache.org" returnType="rtns:>outputReportIncident" xmlns:rtns="http://reportincident.example.camel.apache.org" soapAction="http://reportincident.example.camel.apache.org/ReportIncident" >
<parameter qname="pns:inputReportIncident" xmlns:pns="http://reportincident.example.camel.apache.org" type="tns:>inputReportIncident" xmlns:tns="http://reportincident.example.camel.apache.org"/>
</operation>
<parameter name="allowedMethods" value="reportIncident"/>
<typeMapping
xmlns:ns="http://reportincident.example.camel.apache.org"
qname="ns:>outputReportIncident"
type="java:org.apache.camel.example.reportincident.OutputReportIncident"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
<typeMapping
xmlns:ns="http://reportincident.example.camel.apache.org"
qname="ns:>inputReportIncident"
type="java:org.apache.camel.example.reportincident.InputReportIncident"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle=""
/>
</service>
<!-- part of Axis configuration -->
<transport name="http">
<requestFlow>
<handler type="URLMapper"/>
<handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler"/>
</requestFlow>
</transport>
</deployment>
|
The globalConfiguration and transport is not in the deploy.wsdd file so you gotta write that yourself. The service is a 100% copy from deploy.wsdd. Axis has more configuration to it than shown here, but then you should check the AXIS documentation.
What we need to do now is important, as we need to modify the above configuration to use our webservice class than the default one, so we the classname parameter to:
Code Block |
---|
|
<parameter name="className" value="org.apache.camel.example.axis.AxisReportIncidentService"/>
|