Added JAX-WS client

This commit is contained in:
Arjen Poutsma
2006-10-05 22:25:14 +00:00
parent 3745474190
commit f3ef8cb418
27 changed files with 1573 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
<?xml version="1.0"?>
<project name="spring-ws-airline-sample-jax-ws-client" default="build">
<property name="bin.dir" value="bin"/>
<property name="src.dir" value="src"/>
<property name="lib.dir" value="lib"/>
<target name="init">
<mkdir dir="${bin.dir}"/>
</target>
<target name="generate" depends="init">
<taskdef name="wsimport" classname="com.sun.tools.ws.ant.WsImport">
<classpath>
<pathelement location="${lib.dir}/activation.jar"/>
<pathelement location="${lib.dir}/jaxb-api.jar"/>
<pathelement location="${lib.dir}/jaxb-impl.jar"/>
<pathelement location="${lib.dir}/jaxb-xjc.jar"/>
<pathelement location="${lib.dir}/jaxws-api.jar"/>
<pathelement location="${lib.dir}/jaxws-rt.jar"/>
<pathelement location="${lib.dir}/jaxws-tools.jar"/>
<pathelement location="${lib.dir}/jsr181-api.jar"/>
</classpath>
</taskdef>
<wsimport wsdl="http://localhost:8080/airline/airline.wsdl" destdir="${bin.dir}" sourcedestdir="${src.dir}"
package="org.springframework.ws.samples.airline.client.jws"/>
</target>
<target name="build" depends="init">
<javac srcdir="${src.dir}" destdir="${bin.dir}" debug="true">
<classpath>
<pathelement location="${lib.dir}/activation.jar"/>
<pathelement location="${lib.dir}/jaxb-api.jar"/>
<pathelement location="${lib.dir}/jaxb-impl.jar"/>
<pathelement location="${lib.dir}/jaxws-api.jar"/>
<pathelement location="${lib.dir}/jaxws-rt.jar"/>
<pathelement location="${lib.dir}/jsr181-api.jar"/>
</classpath>
</javac>
</target>
<target name="clean">
<delete dir="${bin.dir}"/>
</target>
<target name="run" depends="build">
<java classname="org.springframework.ws.samples.airline.client.jws.Main" fork="true" failonerror="true">
<classpath>
<pathelement location="${bin.dir}"/>
<pathelement location="${lib.dir}/activation.jar"/>
<pathelement location="${lib.dir}/jaxb-api.jar"/>
<pathelement location="${lib.dir}/jaxb-impl.jar"/>
<pathelement location="${lib.dir}/jaxws-api.jar"/>
<pathelement location="${lib.dir}/jaxws-rt.jar"/>
<pathelement location="${lib.dir}/jsr181-api.jar"/>
<pathelement location="${lib.dir}/resolver.jar"/>
<pathelement location="${lib.dir}/jsr173_api.jar"/>
<pathelement location="${lib.dir}/saaj-api.jar"/>
<pathelement location="${lib.dir}/saaj-impl.jar"/>
<pathelement location="${lib.dir}/sjsxp.jar"/>
</classpath>
</java>
</target>
</project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,59 @@
package org.springframework.ws.samples.airline.client.jws;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.ParameterStyle;
/**
* This class was generated by the JAXWS SI.
* JAX-WS RI 2.0_01-b59-fcs
* Generated source version: 2.0
*
*/
@WebService(name = "AirlinePortType", targetNamespace = "http://www.springframework.org/spring-ws/samples/airline/definitions")
@SOAPBinding(parameterStyle = ParameterStyle.BARE)
public interface AirlinePortType {
/**
*
* @param body
* @return
* returns org.springframework.ws.samples.airline.client.jws.GetFlightsResponse
*/
@WebMethod(operationName = "GetFlights", action = "http://www.springframework.org/spring-ws/samples/airline/GetFlights")
@WebResult(name = "GetFlightsResponse", targetNamespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", partName = "body")
public GetFlightsResponse getFlights(
@WebParam(name = "GetFlightsRequest", targetNamespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", partName = "body")
GetFlightsRequest body);
/**
*
* @param body
* @return
* returns org.springframework.ws.samples.airline.client.jws.Ticket
*/
@WebMethod(operationName = "BookFlight", action = "http://www.springframework.org/spring-ws/samples/airline/BookFlight")
@WebResult(name = "BookFlightResponse", targetNamespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", partName = "body")
public Ticket bookFlight(
@WebParam(name = "BookFlightRequest", targetNamespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", partName = "body")
BookFlightRequest body);
/**
*
* @param body
* @return
* returns int
*/
@WebMethod(operationName = "GetFrequentFlyerMileage", action = "http://www.springframework.org/spring-ws/samples/airline/GetFrequentFlyerMileage")
@WebResult(name = "GetFrequentFlyerMileageResponse", targetNamespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", partName = "body")
public int getFrequentFlyerMileage(
@WebParam(name = "GetFrequentFlyerMileageRequest", targetNamespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", partName = "body")
Object body);
}

View File

@@ -0,0 +1,69 @@
/*
* 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.jws;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
/**
* This class was generated by the JAXWS SI.
* JAX-WS RI 2.0_01-b59-fcs
* Generated source version: 2.0
*
*/
@WebServiceClient(name = "AirlineService", targetNamespace = "http://www.springframework.org/spring-ws/samples/airline/definitions", wsdlLocation = "http://localhost:8080/airline/airline.wsdl")
public class AirlineService
extends Service
{
private final static URL AIRLINESERVICE_WSDL_LOCATION;
static {
URL url = null;
try {
url = new URL("http://localhost:8080/airline/airline.wsdl");
} catch (MalformedURLException e) {
e.printStackTrace();
}
AIRLINESERVICE_WSDL_LOCATION = url;
}
public AirlineService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public AirlineService() {
super(AIRLINESERVICE_WSDL_LOCATION, new QName("http://www.springframework.org/spring-ws/samples/airline/definitions", "AirlineService"));
}
/**
*
* @return
* returns AirlinePortType
*/
@WebEndpoint(name = "AirlinePort")
public AirlinePortType getAirlinePort() {
return (AirlinePortType)super.getPort(new QName("http://www.springframework.org/spring-ws/samples/airline/definitions", "AirlinePort"), AirlinePortType.class);
}
}

View File

@@ -0,0 +1,116 @@
package org.springframework.ws.samples.airline.client.jws;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for Airport complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="Airport">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;all>
* &lt;element name="code" type="{http://www.springframework.org/spring-ws/samples/airline/schemas}AirportCode"/>
* &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="city" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;/all>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Airport", propOrder = {
})
public class Airport {
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected String code;
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected String name;
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected String city;
/**
* Gets the value of the code property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCode() {
return code;
}
/**
* Sets the value of the code property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCode(String value) {
this.code = value;
}
/**
* Gets the value of the name property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getName() {
return name;
}
/**
* Sets the value of the name property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setName(String value) {
this.name = value;
}
/**
* Gets the value of the city property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCity() {
return city;
}
/**
* Sets the value of the city property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCity(String value) {
this.city = value;
}
}

View File

@@ -0,0 +1,217 @@
/*
* 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.jws;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;
import org.springframework.ws.samples.airline.client.jws.BookFlightRequest.Passengers;
/**
* <p>Java class for BookFlightRequest element declaration.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;element name="BookFlightRequest">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;all>
* &lt;element name="flightNumber" type="{http://www.springframework.org/spring-ws/samples/airline/schemas}FlightNumber"/>
* &lt;element name="departureTime" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
* &lt;element name="passengers">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;choice maxOccurs="9">
* &lt;element name="passenger" type="{http://www.springframework.org/spring-ws/samples/airline/schemas}Name"/>
* &lt;element name="username" type="{http://www.springframework.org/spring-ws/samples/airline/schemas}FrequentFlyerUsername"/>
* &lt;/choice>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* &lt;/all>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
})
@XmlRootElement(name = "BookFlightRequest")
public class BookFlightRequest {
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected String flightNumber;
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected XMLGregorianCalendar departureTime;
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected Passengers passengers;
/**
* Gets the value of the flightNumber property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getFlightNumber() {
return flightNumber;
}
/**
* Sets the value of the flightNumber property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setFlightNumber(String value) {
this.flightNumber = value;
}
/**
* Gets the value of the departureTime property.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getDepartureTime() {
return departureTime;
}
/**
* Sets the value of the departureTime property.
*
* @param value
* allowed object is
* {@link XMLGregorianCalendar }
*
*/
public void setDepartureTime(XMLGregorianCalendar value) {
this.departureTime = value;
}
/**
* Gets the value of the passengers property.
*
* @return
* possible object is
* {@link Passengers }
*
*/
public Passengers getPassengers() {
return passengers;
}
/**
* Sets the value of the passengers property.
*
* @param value
* allowed object is
* {@link Passengers }
*
*/
public void setPassengers(Passengers value) {
this.passengers = value;
}
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;choice maxOccurs="9">
* &lt;element name="passenger" type="{http://www.springframework.org/spring-ws/samples/airline/schemas}Name"/>
* &lt;element name="username" type="{http://www.springframework.org/spring-ws/samples/airline/schemas}FrequentFlyerUsername"/>
* &lt;/choice>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"passengerOrUsername"
})
public static class Passengers {
@XmlElements({
@XmlElement(name = "passenger", namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true, type = Name.class),
@XmlElement(name = "username", namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true, type = String.class)
})
protected List<Object> passengerOrUsername;
/**
* Gets the value of the passengerOrUsername property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the passengerOrUsername property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getPassengerOrUsername().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Name }
* {@link String }
*
*
*/
public List<Object> getPassengerOrUsername() {
if (passengerOrUsername == null) {
passengerOrUsername = new ArrayList<Object>();
}
return this.passengerOrUsername;
}
}
}

View File

@@ -0,0 +1,203 @@
package org.springframework.ws.samples.airline.client.jws;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;
/**
* <p>Java class for Flight complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="Flight">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="number" type="{http://www.springframework.org/spring-ws/samples/airline/schemas}FlightNumber"/>
* &lt;element name="departureTime" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
* &lt;element name="from" type="{http://www.springframework.org/spring-ws/samples/airline/schemas}Airport"/>
* &lt;element name="arrivalTime" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
* &lt;element name="to" type="{http://www.springframework.org/spring-ws/samples/airline/schemas}Airport"/>
* &lt;element name="serviceClass" type="{http://www.springframework.org/spring-ws/samples/airline/schemas}ServiceClass"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Flight", propOrder = {
"number",
"departureTime",
"from",
"arrivalTime",
"to",
"serviceClass"
})
public class Flight {
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected String number;
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected XMLGregorianCalendar departureTime;
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected Airport from;
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected XMLGregorianCalendar arrivalTime;
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected Airport to;
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected ServiceClass serviceClass;
/**
* Gets the value of the number property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getNumber() {
return number;
}
/**
* Sets the value of the number property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setNumber(String value) {
this.number = value;
}
/**
* Gets the value of the departureTime property.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getDepartureTime() {
return departureTime;
}
/**
* Sets the value of the departureTime property.
*
* @param value
* allowed object is
* {@link XMLGregorianCalendar }
*
*/
public void setDepartureTime(XMLGregorianCalendar value) {
this.departureTime = value;
}
/**
* Gets the value of the from property.
*
* @return
* possible object is
* {@link Airport }
*
*/
public Airport getFrom() {
return from;
}
/**
* Sets the value of the from property.
*
* @param value
* allowed object is
* {@link Airport }
*
*/
public void setFrom(Airport value) {
this.from = value;
}
/**
* Gets the value of the arrivalTime property.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getArrivalTime() {
return arrivalTime;
}
/**
* Sets the value of the arrivalTime property.
*
* @param value
* allowed object is
* {@link XMLGregorianCalendar }
*
*/
public void setArrivalTime(XMLGregorianCalendar value) {
this.arrivalTime = value;
}
/**
* Gets the value of the to property.
*
* @return
* possible object is
* {@link Airport }
*
*/
public Airport getTo() {
return to;
}
/**
* Sets the value of the to property.
*
* @param value
* allowed object is
* {@link Airport }
*
*/
public void setTo(Airport value) {
this.to = value;
}
/**
* Gets the value of the serviceClass property.
*
* @return
* possible object is
* {@link ServiceClass }
*
*/
public ServiceClass getServiceClass() {
return serviceClass;
}
/**
* Sets the value of the serviceClass property.
*
* @param value
* allowed object is
* {@link ServiceClass }
*
*/
public void setServiceClass(ServiceClass value) {
this.serviceClass = value;
}
}

View File

@@ -0,0 +1,148 @@
package org.springframework.ws.samples.airline.client.jws;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;
/**
* <p>Java class for GetFlightsRequest element declaration.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;element name="GetFlightsRequest">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;all>
* &lt;element name="from" type="{http://www.springframework.org/spring-ws/samples/airline/schemas}AirportCode"/>
* &lt;element name="to" type="{http://www.springframework.org/spring-ws/samples/airline/schemas}AirportCode"/>
* &lt;element name="departureDate" type="{http://www.w3.org/2001/XMLSchema}date"/>
* &lt;element name="serviceClass" type="{http://www.springframework.org/spring-ws/samples/airline/schemas}ServiceClass" minOccurs="0"/>
* &lt;/all>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
})
@XmlRootElement(name = "GetFlightsRequest")
public class GetFlightsRequest {
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected String from;
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected String to;
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected XMLGregorianCalendar departureDate;
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas")
protected ServiceClass serviceClass;
/**
* Gets the value of the from property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getFrom() {
return from;
}
/**
* Sets the value of the from property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setFrom(String value) {
this.from = value;
}
/**
* Gets the value of the to property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getTo() {
return to;
}
/**
* Sets the value of the to property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setTo(String value) {
this.to = value;
}
/**
* Gets the value of the departureDate property.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getDepartureDate() {
return departureDate;
}
/**
* Sets the value of the departureDate property.
*
* @param value
* allowed object is
* {@link XMLGregorianCalendar }
*
*/
public void setDepartureDate(XMLGregorianCalendar value) {
this.departureDate = value;
}
/**
* Gets the value of the serviceClass property.
*
* @return
* possible object is
* {@link ServiceClass }
*
*/
public ServiceClass getServiceClass() {
return serviceClass;
}
/**
* Sets the value of the serviceClass property.
*
* @param value
* allowed object is
* {@link ServiceClass }
*
*/
public void setServiceClass(ServiceClass value) {
this.serviceClass = value;
}
}

View File

@@ -0,0 +1,89 @@
/*
* 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.jws;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for GetFlightsResponse element declaration.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;element name="GetFlightsResponse">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="flight" type="{http://www.springframework.org/spring-ws/samples/airline/schemas}Flight" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"flight"
})
@XmlRootElement(name = "GetFlightsResponse")
public class GetFlightsResponse {
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected List<Flight> flight;
/**
* Gets the value of the flight property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the flight property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getFlight().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Flight }
*
*
*/
public List<Flight> getFlight() {
if (flight == null) {
flight = new ArrayList<Flight>();
}
return this.flight;
}
}

View File

@@ -0,0 +1,102 @@
/*
* 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.jws;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;
import javax.xml.ws.soap.SOAPFaultException;
/**
* Simple client that calls the <code>GetFlights</code> and <code>BookFlight</code> operations using JAX-WS.
*
* @author Arjen Poutsma
*/
public class Main {
public static void main(String[] args) throws MalformedURLException, DatatypeConfigurationException {
try {
AirlineService service;
if (args.length == 0) {
service = new AirlineService();
}
else {
QName serviceName = new QName("http://www.springframework.org/spring-ws/samples/airline/definitions",
"AirlineService");
service = new AirlineService(new URL(args[0]), serviceName);
}
AirlinePortType portType = service.getAirlinePort();
GetFlightsRequest request = new GetFlightsRequest();
request.setFrom("AMS");
request.setTo("VCE");
XMLGregorianCalendar departureDate =
DatatypeFactory.newInstance().newXMLGregorianCalendarDate(2006, 1, 31, 0);
request.setDepartureDate(departureDate);
System.out.format("Requesting flights on %1tD%n", departureDate.toGregorianCalendar());
GetFlightsResponse response = portType.getFlights(request);
System.out.format("Got %1d results%n", response.getFlight().size());
if (!response.getFlight().isEmpty())
// Book the first flight using John Doe as a frequent flyer
{
Flight flight = response.getFlight().get(0);
BookFlightRequest bookFlightRequest = new BookFlightRequest();
bookFlightRequest.setFlightNumber(flight.getNumber());
bookFlightRequest.setDepartureTime(flight.getDepartureTime());
BookFlightRequest.Passengers passengers = new BookFlightRequest.Passengers();
passengers.getPassengerOrUsername().add("john");
bookFlightRequest.setPassengers(passengers);
Ticket ticket = portType.bookFlight(bookFlightRequest);
writeTicket(ticket);
}
}
catch (SOAPFaultException ex) {
System.out.format("SOAP Fault Code %1s%n", ex.getFault().getFaultCodeAsQName());
System.out.format("SOAP Fault String: %1s%n", ex.getFault().getFaultString());
}
}
private static void writeTicket(Ticket ticket) {
System.out.format("Ticket %1d%n", ticket.getId());
System.out.format("Ticket issue date:\t%1tD%n", ticket.getIssueDate().toGregorianCalendar());
for (Name passenger : ticket.getPassengers().getPassenger()) {
writeName(passenger);
}
writeFlight(ticket.flight);
}
private static void writeName(Name name) {
System.out.format("Passenger Name:%n");
System.out.format("%1s %2s%n", name.getFirst(), name.getLast());
System.out.format("------------%n");
}
private static void writeFlight(Flight flight) {
System.out.format("%1tD%n", flight.getDepartureTime().toGregorianCalendar());
System.out.format("%1s\t%2s%n", flight.getNumber(), flight.getServiceClass());
System.out.format("------------%n");
System.out.format("Depart:\t%1s-%2s\t%tR%n", flight.getFrom().getCode(), flight.getFrom().getName(), flight.getDepartureTime().toGregorianCalendar());
System.out.format("\t%1s%n", flight.getFrom().getCity());
System.out.format("Arrive:\t%1s-%2s\t%tR%n", flight.getTo().getCode(), flight.getTo().getName(), flight.getArrivalTime().toGregorianCalendar());
System.out.format("\t%1s%n", flight.getTo().getCity());
}
}

View File

@@ -0,0 +1,90 @@
package org.springframework.ws.samples.airline.client.jws;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for Name complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="Name">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="first" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="last" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Name", propOrder = {
"first",
"last"
})
public class Name {
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected String first;
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected String last;
/**
* Gets the value of the first property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getFirst() {
return first;
}
/**
* Sets the value of the first property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setFirst(String value) {
this.first = value;
}
/**
* Gets the value of the last property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getLast() {
return last;
}
/**
* Sets the value of the last property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setLast(String value) {
this.last = value;
}
}

View File

@@ -0,0 +1,137 @@
package org.springframework.ws.samples.airline.client.jws;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the org.springframework.ws.samples.airline.client.jws package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {
private final static QName _GetFrequentFlyerMileageResponse_QNAME = new QName("http://www.springframework.org/spring-ws/samples/airline/schemas", "GetFrequentFlyerMileageResponse");
private final static QName _BookFlightResponse_QNAME = new QName("http://www.springframework.org/spring-ws/samples/airline/schemas", "BookFlightResponse");
private final static QName _GetFrequentFlyerMileageRequest_QNAME = new QName("http://www.springframework.org/spring-ws/samples/airline/schemas", "GetFrequentFlyerMileageRequest");
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.springframework.ws.samples.airline.client.jws
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link org.springframework.ws.samples.airline.client.jws.Ticket.Passengers }
*
*/
public org.springframework.ws.samples.airline.client.jws.Ticket.Passengers createTicketPassengers() {
return new org.springframework.ws.samples.airline.client.jws.Ticket.Passengers();
}
/**
* Create an instance of {@link Flight }
*
*/
public Flight createFlight() {
return new Flight();
}
/**
* Create an instance of {@link Airport }
*
*/
public Airport createAirport() {
return new Airport();
}
/**
* Create an instance of {@link GetFlightsRequest }
*
*/
public GetFlightsRequest createGetFlightsRequest() {
return new GetFlightsRequest();
}
/**
* Create an instance of {@link GetFlightsResponse }
*
*/
public GetFlightsResponse createGetFlightsResponse() {
return new GetFlightsResponse();
}
/**
* Create an instance of {@link org.springframework.ws.samples.airline.client.jws.BookFlightRequest.Passengers }
*
*/
public org.springframework.ws.samples.airline.client.jws.BookFlightRequest.Passengers createBookFlightRequestPassengers() {
return new org.springframework.ws.samples.airline.client.jws.BookFlightRequest.Passengers();
}
/**
* Create an instance of {@link BookFlightRequest }
*
*/
public BookFlightRequest createBookFlightRequest() {
return new BookFlightRequest();
}
/**
* Create an instance of {@link Name }
*
*/
public Name createName() {
return new Name();
}
/**
* Create an instance of {@link Ticket }
*
*/
public Ticket createTicket() {
return new Ticket();
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link Integer }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", name = "GetFrequentFlyerMileageResponse")
public JAXBElement<Integer> createGetFrequentFlyerMileageResponse(Integer value) {
return new JAXBElement<Integer>(_GetFrequentFlyerMileageResponse_QNAME, Integer.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link Ticket }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", name = "BookFlightResponse")
public JAXBElement<Ticket> createBookFlightResponse(Ticket value) {
return new JAXBElement<Ticket>(_BookFlightResponse_QNAME, Ticket.class, null, value);
}
/**
* Create an instance of {@link JAXBElement }{@code <}{@link Object }{@code >}}
*
*/
@XmlElementDecl(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", name = "GetFrequentFlyerMileageRequest")
public JAXBElement<Object> createGetFrequentFlyerMileageRequest(Object value) {
return new JAXBElement<Object>(_GetFrequentFlyerMileageRequest_QNAME, Object.class, null, value);
}
}

View File

@@ -0,0 +1,52 @@
package org.springframework.ws.samples.airline.client.jws;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
/**
* <p>Java class for ServiceClass.
*
* <p>The following schema fragment specifies the expected content contained within this class.
* <p>
* <pre>
* &lt;simpleType name="ServiceClass">
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}NCName">
* &lt;enumeration value="economy"/>
* &lt;enumeration value="business"/>
* &lt;enumeration value="first"/>
* &lt;/restriction>
* &lt;/simpleType>
* </pre>
*
*/
@XmlEnum
public enum ServiceClass {
@XmlEnumValue("business")
BUSINESS("business"),
@XmlEnumValue("economy")
ECONOMY("economy"),
@XmlEnumValue("first")
FIRST("first");
private final String value;
ServiceClass(String v) {
value = v;
}
public String value() {
return value;
}
public static ServiceClass fromValue(String v) {
for (ServiceClass c: ServiceClass.values()) {
if (c.value.equals(v)) {
return c;
}
}
throw new IllegalArgumentException(v.toString());
}
}

View File

@@ -0,0 +1,225 @@
/*
* 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.jws;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;
import org.springframework.ws.samples.airline.client.jws.Ticket.Passengers;
/**
* <p>Java class for Ticket complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="Ticket">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;all>
* &lt;element name="id" type="{http://www.w3.org/2001/XMLSchema}long"/>
* &lt;element name="issueDate" type="{http://www.w3.org/2001/XMLSchema}date"/>
* &lt;element name="passengers">
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="passenger" type="{http://www.springframework.org/spring-ws/samples/airline/schemas}Name" maxOccurs="9"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* &lt;/element>
* &lt;element name="flight" type="{http://www.springframework.org/spring-ws/samples/airline/schemas}Flight"/>
* &lt;/all>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Ticket", propOrder = {
})
public class Ticket {
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas")
protected long id;
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected XMLGregorianCalendar issueDate;
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected Passengers passengers;
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected Flight flight;
/**
* Gets the value of the id property.
*
*/
public long getId() {
return id;
}
/**
* Sets the value of the id property.
*
*/
public void setId(long value) {
this.id = value;
}
/**
* Gets the value of the issueDate property.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getIssueDate() {
return issueDate;
}
/**
* Sets the value of the issueDate property.
*
* @param value
* allowed object is
* {@link XMLGregorianCalendar }
*
*/
public void setIssueDate(XMLGregorianCalendar value) {
this.issueDate = value;
}
/**
* Gets the value of the passengers property.
*
* @return
* possible object is
* {@link Passengers }
*
*/
public Passengers getPassengers() {
return passengers;
}
/**
* Sets the value of the passengers property.
*
* @param value
* allowed object is
* {@link Passengers }
*
*/
public void setPassengers(Passengers value) {
this.passengers = value;
}
/**
* Gets the value of the flight property.
*
* @return
* possible object is
* {@link Flight }
*
*/
public Flight getFlight() {
return flight;
}
/**
* Sets the value of the flight property.
*
* @param value
* allowed object is
* {@link Flight }
*
*/
public void setFlight(Flight value) {
this.flight = value;
}
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="passenger" type="{http://www.springframework.org/spring-ws/samples/airline/schemas}Name" maxOccurs="9"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"passenger"
})
public static class Passengers {
@XmlElement(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas", required = true)
protected List<Name> passenger;
/**
* Gets the value of the passenger property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the passenger property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getPassenger().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Name }
*
*
*/
public List<Name> getPassenger() {
if (passenger == null) {
passenger = new ArrayList<Name>();
}
return this.passenger;
}
}
}

View File

@@ -0,0 +1,2 @@
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.springframework.org/spring-ws/samples/airline/schemas")
package org.springframework.ws.samples.airline.client.jws;