Added Axis1 client
This commit is contained in:
79
samples/airline/client/axis1/build.xml
Normal file
79
samples/airline/client/axis1/build.xml
Normal file
@@ -0,0 +1,79 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<project name="spring-ws-airline-sample-saaj-client" default="build"
|
||||
xmlns:artifact="urn:maven-artifact-ant">
|
||||
<property name="bin.dir" value="bin"/>
|
||||
<property name="src.dir" value="src"/>
|
||||
<property name="gen.dir" value="gen"/>
|
||||
<property name="wsdl" value="${basedir}/../../src/main/webapp/airline.wsdl"/>
|
||||
|
||||
<target name="init">
|
||||
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant">
|
||||
<classpath>
|
||||
<pathelement location="${basedir}/../maven-artifact-ant-2.0.4-dep.jar"/>
|
||||
</classpath>
|
||||
</typedef>
|
||||
|
||||
<!-- <artifact:remoteRepository id="java.net" url="https://maven-repository.dev.java.net/nonav/repository" -->
|
||||
<!-- layout="legacy"/> -->
|
||||
|
||||
<artifact:dependencies pathId="generate.classpath">
|
||||
<dependency groupId="axis" artifactId="axis-ant" version="1.4"/>
|
||||
<dependency groupId="axis" artifactId="axis" version="1.4"/>
|
||||
</artifact:dependencies>
|
||||
|
||||
<artifact:dependencies pathId="compile.classpath">
|
||||
<dependency groupId="axis" artifactId="axis" version="1.4"/>
|
||||
</artifact:dependencies>
|
||||
<!-- -->
|
||||
<!-- <artifact:dependencies pathId="runtime.classpath"> -->
|
||||
<!-- <remoteRepository refid="java.net" /> -->
|
||||
<!-- <dependency groupId="com.sun.xml.messaging.saaj" artifactId="saaj-impl" version="1.3"/> -->
|
||||
<!-- </artifact:dependencies> -->
|
||||
</target>
|
||||
|
||||
<target name="generate" depends="init">
|
||||
<mkdir dir="${gen.dir}"/>
|
||||
<taskdef resource="axis-tasks.properties" classpathref="generate.classpath"/>
|
||||
|
||||
<axis-wsdl2java
|
||||
output="${gen.dir}"
|
||||
url="${wsdl}">
|
||||
<mapping
|
||||
namespace="http://www.springframework.org/spring-ws/samples/airline/schemas"
|
||||
package="org.springframework.ws.samples.airline.client.axis1"/>
|
||||
<mapping
|
||||
namespace="http://www.springframework.org/spring-ws/samples/airline/definitions"
|
||||
package="org.springframework.ws.samples.airline.client.axis1"/>
|
||||
</axis-wsdl2java>
|
||||
|
||||
</target>
|
||||
|
||||
|
||||
<target name="build" depends="init">
|
||||
<mkdir dir="${bin.dir}"/>
|
||||
<javac destdir="${bin.dir}">
|
||||
<src path="${src.dir}"/>
|
||||
<src path="${gen.dir}"/>
|
||||
<classpath refid="compile.classpath"/>
|
||||
</javac>
|
||||
<copy todir="${bin.dir}">
|
||||
<fileset dir="${src.dir}">
|
||||
<exclude name="**/*.java"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="${bin.dir}"/>
|
||||
<delete dir="${gen.dir}"/>
|
||||
</target>
|
||||
|
||||
<target name="run" depends="build">
|
||||
<java classname="org.springframework.ws.samples.airline.client.axis1.Main" fork="true" failonerror="true">
|
||||
<classpath refid="compile.classpath"/>
|
||||
<classpath location="${bin.dir}"/>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright 2006 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ws.samples.airline.client.axis1;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Calendar;
|
||||
import javax.xml.rpc.ServiceException;
|
||||
|
||||
/**
|
||||
* Simple client that calls the <code>GetFlights</code> and <code>BookFlight</code> operations using JAX-RPC (Axis 1).
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) throws ServiceException, RemoteException {
|
||||
AirlineServiceLocator service = new AirlineServiceLocator();
|
||||
if (args.length > 0) {
|
||||
service.setAirlinePortEndpointAddress(args[0]);
|
||||
}
|
||||
AirlinePortType portType = service.getAirlinePort();
|
||||
GetFlightsRequest request = new GetFlightsRequest();
|
||||
request.setFrom("AMS");
|
||||
request.setTo("VCE");
|
||||
Calendar departureCalendar = Calendar.getInstance();
|
||||
departureCalendar.set(Calendar.YEAR, 2006);
|
||||
departureCalendar.set(Calendar.MONTH, Calendar.JANUARY);
|
||||
departureCalendar.set(Calendar.DATE, 31);
|
||||
Date departureDate = departureCalendar.getTime();
|
||||
request.setDepartureDate(departureDate);
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
System.out.println("Requesting flights on " + dateFormat.format(departureDate));
|
||||
Flight[] flights = portType.getFlights(request);
|
||||
System.out.println("Got " + flights.length + " results");
|
||||
if (flights.length > 0)
|
||||
{
|
||||
// Book the first flight using John Doe as a frequent flyer
|
||||
BookFlightRequest bookFlightRequest = new BookFlightRequest();
|
||||
bookFlightRequest.setFlightNumber(flights[0].getNumber());
|
||||
bookFlightRequest.setDepartureTime(flights[0].getDepartureTime());
|
||||
BookFlightRequestPassengers passengers = new BookFlightRequestPassengers();
|
||||
passengers.setUsername("john");
|
||||
bookFlightRequest.setPassengers(passengers);
|
||||
Ticket ticket = portType.bookFlight(bookFlightRequest);
|
||||
writeTicket(ticket);
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeTicket(Ticket ticket) {
|
||||
System.out.println("Ticket " + ticket.getId());
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
||||
System.out.println("Ticket issue date:\t" + dateFormat.format(ticket.getIssueDate()));
|
||||
for (int i = 0; i < ticket.getPassengers().length; i++) {
|
||||
writeName(ticket.getPassengers()[i]);
|
||||
|
||||
}
|
||||
writeFlight(ticket.getFlight());
|
||||
}
|
||||
|
||||
private static void writeName(Name name) {
|
||||
System.out.println("Passenger Name:");
|
||||
System.out.println(name.getFirst() + " " + name.getLast());
|
||||
System.out.println("------------");
|
||||
}
|
||||
|
||||
private static void writeFlight(Flight flight) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
System.out.println(dateFormat.format(flight.getDepartureTime().getTime()));
|
||||
System.out.println(flight.getNumber() + "\t" + flight.getServiceClass());
|
||||
System.out.println("------------");
|
||||
System.out.println("Depart:\t" + flight.getFrom().getCode() + "-" + flight.getFrom().getName() + "\t" + dateFormat.format(flight.getDepartureTime().getTime()));
|
||||
System.out.println("\t" + flight.getFrom().getCity());
|
||||
System.out.println("Arrive:\t" + flight.getTo().getCode() + "-" + flight.getTo().getName() + "\t" + dateFormat.format(flight.getArrivalTime().getTime()));
|
||||
System.out.println("\t" + flight.getTo().getCity());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user