001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019: package org.apache.axis2.jaxws.proxy.rpclit;
020:
021: import java.math.BigInteger;
022:
023: import javax.jws.WebService;
024: import javax.xml.bind.annotation.XmlList;
025: import javax.xml.datatype.DatatypeConstants;
026: import javax.xml.datatype.DatatypeFactory;
027: import javax.xml.datatype.XMLGregorianCalendar;
028: import javax.xml.namespace.QName;
029: import javax.xml.ws.Holder;
030:
031: import org.apache.axis2.jaxws.proxy.rpclit.sei.RPCFault;
032: import org.apache.axis2.jaxws.proxy.rpclit.sei.RPCLit;
033: import org.apache.axis2.jaxws.TestLogger;
034: import org.test.proxy.rpclit.ComplexAll;
035: import org.test.proxy.rpclit.Enum;
036:
037: /**
038: *
039: *
040: */
041: @WebService(targetNamespace="http://org/apache/axis2/jaxws/proxy/rpclit",endpointInterface="org.apache.axis2.jaxws.proxy.rpclit.sei.RPCLit")
042: public class RPCLitImpl implements RPCLit {
043:
044: public static DatatypeFactory df;
045: public static XMLGregorianCalendar bday;
046: public static XMLGregorianCalendar holiday;
047: public static BigInteger bigInt1 = new BigInteger("1");
048: public static BigInteger bigInt2 = new BigInteger("2");
049: public static QName qname1 = new QName("urn://sample", "hello");
050: public static QName qname2 = new QName("urn://sample", "world");
051:
052: static {
053: try {
054: df = DatatypeFactory.newInstance();
055: bday = df.newXMLGregorianCalendarDate(1964, 12, 3,
056: DatatypeConstants.FIELD_UNDEFINED);
057: holiday = bday = df.newXMLGregorianCalendarDate(2007, 1, 1,
058: DatatypeConstants.FIELD_UNDEFINED);
059: } catch (Exception e) {
060: }
061: }
062:
063: /**
064: * Echo the input
065: */
066: public String testSimple(String simpleIn) {
067: assertTrue(simpleIn != null); // According to JAX-WS an RPC service should never receive a null
068:
069: // Test to ensure that returning null causes the proper exception
070: if (simpleIn.contains("returnNull")) {
071: return null;
072: }
073: return simpleIn;
074: }
075:
076: /**
077: * Echo the input
078: */
079: public String testSimple2(String simple2In1, String simple2In2) {
080: return simple2In1 + simple2In2;
081: }
082:
083: public QName[] testLists(QName[] qNames,
084: XMLGregorianCalendar[] calendars, String[] texts,
085: BigInteger[] bigInts, Long[] longs, Enum[] enums,
086: String[] text2, ComplexAll all) {
087: assertTrue(qNames.length == 2);
088: assertTrue(qNames[0].equals(qname1));
089: assertTrue(qNames[1].equals(qname2));
090:
091: return qNames;
092: }
093:
094: public XMLGregorianCalendar[] testCalendarList1(
095: XMLGregorianCalendar[] cals) {
096: assertTrue(cals.length == 2);
097: assertTrue(cals[0].compare(bday) == 0);
098: assertTrue(cals[1].compare(holiday) == 0);
099: return cals;
100:
101: }
102:
103: public String[] testStringList2(String[] arg20) {
104:
105: assertTrue(arg20.length == 2);
106: assertTrue(arg20[0].equals("Hello"));
107: assertTrue(arg20[1].equals("World"));
108: return arg20;
109: }
110:
111: public BigInteger[] testBigIntegerList3(BigInteger[] arg30) {
112: assertTrue(arg30.length == 2);
113: assertTrue(arg30[0].compareTo(bigInt1) == 0);
114: assertTrue(arg30[1].compareTo(bigInt2) == 0);
115: return arg30;
116: }
117:
118: public Long[] testLongList4(Long[] longs) {
119: assertTrue(longs.length == 3);
120: assertTrue(longs[0] == 0);
121: assertTrue(longs[1] == 1);
122: assertTrue(longs[2] == 2);
123: return longs;
124: }
125:
126: public Enum[] testEnumList5(Enum[] enums) {
127: assertTrue(enums.length == 3);
128: assertTrue(enums[0] == Enum.ONE);
129: assertTrue(enums[1] == Enum.TWO);
130: assertTrue(enums[2] == Enum.THREE);
131: return enums;
132: }
133:
134: public ComplexAll testComplexAll6(ComplexAll arg60) {
135: // TODO Auto-generated method stub
136: return null;
137: }
138:
139: public String[] testEnumList7(String[] arg70) {
140: assertTrue(arg70.length == 2);
141: assertTrue(arg70[0].equals("Apple"));
142: assertTrue(arg70[0].equals("Orange"));
143: return arg70;
144: }
145:
146: private void assertTrue(boolean value) throws RuntimeException {
147: if (!value) {
148: RuntimeException re = new RuntimeException();
149: TestLogger.logger.debug("Test FAILURE=" + re);
150: throw re;
151: }
152: }
153:
154: public String testHeader(String bodyParam, String headerParam) {
155: return bodyParam + headerParam;
156: }
157:
158: public void testFault() throws RPCFault {
159: throw new RPCFault("Throw RPCFault", 123);
160: }
161:
162: public String testSimpleInOut(Holder<String> simpleInOut) {
163: return simpleInOut.value;
164: }
165:
166: }
|