package web;
/*
* Copyright 2004-2005 The Apache Software Foundation
*
* 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.
*
* $Header:$
*/
import javax.xml.rpc.holders.CalendarHolder;
import javax.xml.rpc.holders.StringHolder;
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import org.apache.beehive.sample.wsm.addressbook_enhanced.Address;
import org.apache.beehive.sample.wsm.addressbook_enhanced.AddressBookImpl;
import org.apache.beehive.sample.wsm.addressbook_enhanced.EnhancedAddressBook;
import org.apache.beehive.sample.wsm.addressbook_enhanced.InvalidAddressException;
import org.apache.beehive.sample.wsm.addressbook_enhanced.InvalidNameException;
import org.apache.beehive.sample.wsm.addressbook_enhanced.Phone;
import org.apache.beehive.sample.wsm.addressbook_enhanced.StateType;
@WebService(
targetNamespace="http://beehive.apache.org/enhancedaddressbook",
serviceName="EnhancedAddressBook"
)
public class Service implements EnhancedAddressBook {
private static String DEFAULT_NAME = "default";
private EnhancedAddressBook addressBook;
/**
* Constructor.
*/
public Service() {
addressBook = new AddressBookImpl();
try {
addressBook.addEntry(
DEFAULT_NAME,
new Address(
10230,
"NE Points Drive",
"Kirkland",
new StateType("WA"),
98033,
new Phone(425, "555", "1234")
)
);
}
catch (InvalidNameException e) {
throw new RuntimeException("cannot add entry to address book");
}
catch (InvalidAddressException e) {
throw new RuntimeException("cannot add entry to address book");
}
}
/**
* Web method that adds an entry to the address book.
* @param name The name under which the address is added to the address
* book.
* @param address The address to be added.
* @throws InvalidNameException
* @throws InvalidAddressException
*/
@WebMethod
public void addEntry(@WebParam (name="custom_name")String name, @WebParam (name="custom_address")Address address)
throws InvalidNameException, InvalidAddressException
{
addressBook.addEntry(name, address);
}
/**
* Web method that queries the address book.
* @param name Name for which the address is returned.
* @return Address for the passed in name.
* @throws InvalidNameException
*/
@WebMethod
public Address getAddressFromName(@WebParam (name="custom_name") String name)
throws InvalidNameException
{
return addressBook.getAddressFromName(name);
}
/**
* Web method that queries the address book.
* @param name Array of names for which the addresses are returned.
* @return Array of addresses for the passed in names.
* @throws InvalidNameException
*/
@WebMethod
public Address[] getAddressFromNames(@WebParam (name="custom_name") String[] name)
throws InvalidNameException
{
return addressBook.getAddressFromNames(name);
}
/**
* Simple Oneway web method that doesn't take any input params.
*/
@WebMethod
@Oneway
public void oneWayWithNoParam() {
return;
}
/**
* Web method that takes one in/out param.
* @param calendar In out parameter; its value is overwritten inside this
* method.
* @return A random string.
*/
@WebMethod
public String oneINOUTParamMethod (@WebParam (name="calendar", mode=WebParam.Mode.INOUT) CalendarHolder calendar) {
return addressBook.oneINOUTParamMethod(calendar);
}
/**
* Simple web method that doesn't take any input params.
* @return A random string.
*/
@WebMethod
public String simpleNoParamMethod() {
return "simpleNoParamMethod()";
}
/**
* Simple method that is not exposed by the web service and can only be used
* locally.
* @return A random string.
*/
public String notWebService() {
return "notWebService()";
}
}