File: Service.java

package info (click to toggle)
axis 1.4-29
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 52,100 kB
  • sloc: java: 129,124; xml: 10,602; jsp: 983; sh: 84; cs: 36; makefile: 18
file content (171 lines) | stat: -rw-r--r-- 4,039 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
package test.RPCDispatch;

import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.AxisFault;
import org.apache.axis.message.RPCElement;
import org.apache.axis.utils.DOM2Writer;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

/**
 * Test WebService
 */
public class Service {

    /**
     * Reverse the order of characters in a string
     */
    public String reverseString(String input) throws Exception {
       String result = "";
       for (int i=input.length(); i>0; ) result+=input.charAt(--i);
       return result;
    }

    /**
     * Concatenate two strings - used to test out-of-order parameter
     * matching.
     */
    public String concatenate(String a1, String a2)
    {
        return a1 + a2;
    }

    /**
     * Reverse the order of a struct
     */
    public Data reverseData(Data input) throws Exception {
       Data result = new Data();
       result.setField1(input.getField3());
       result.setField2(reverseString(input.getField2()));
       result.setField3(input.getField1());
       return result;
    }

    /**
     * Return the target service (should be this!)
     */
    public String targetServiceImplicit() throws Exception {
       return MessageContext.getCurrentContext().getTargetService();
    }

    /**
     * Return the target service (should be this!)
     */
    public String argAsDOM(Data input) throws Exception {

       // get the first parameter
       Message message = MessageContext.getCurrentContext().getRequestMessage();
       RPCElement body = (RPCElement)message.getSOAPEnvelope().getFirstBody();
       NodeList parms = body.getAsDOM().getChildNodes();
       Node parm1 = null;
       for (int i=0; i<parms.getLength(); i++) {
           parm1 = parms.item(i);
           if (parm1.getNodeType() == Node.ELEMENT_NODE) break;
       }

       // convert it to a DOM and back to a string, and return the result.
       return DOM2Writer.nodeToString(parm1, true);

    }

    /**
     * Return the value passed (including nulls!)
     */
    public Integer echoInt(Integer value) throws Exception {
       return value;
    }

    /**
     * Return the boolean and String arguments concatenated
     */
    public String overloaded(boolean b, String s)
    {
        return b + s;
    }

    /**
     * Return the String and boolean arguments concatenated
     */
    public String overloaded(String s, boolean b)
    {
        return s + b;
    }

    /**
     * Return the boolean value passed in
     */
    public boolean overloaded(boolean b)
    {
        return b;
    }

    /**
     * Return the Boolean value passed in
     */
    public Boolean testBoolean(Boolean b)
    {
        return b;
    }

    /**
     * Return the Float value passed in
     */
    public Float testFloat(Float b)
    {
        return b;
    }

    /**
     * Return the Double value passed in
     */
    public Double testDouble(Double b)
    {
        return b;
    }

    /**
     * Return the int passed in (this and the function above test overloaded
     * method dispatch)
     */
    public int overloaded(int i)
    {
        return i;
    }

    /**
     * Return the int and String arguments concatenated
     */
    public String overloaded(int i, String s)
    {
        return i + s;
    }
    
    /**
     * Echo a string array (this is for testing that String->String[]
     * conversions do NOT happen when using encoded arrays)
     */ 
    public void arrayMethod(String [] arg) throws AxisFault {
        throw new AxisFault("You shouldn't have called me!");
    }

    /**
     * Simple exception to be used in generating faults
     */
    class TestFault extends Exception {
        TestFault(String msg) throws Exception {
            super(msg);
            if (msg == null) throw new Exception("default value");
        }
    }

    /**
     * Simple fault.
     */
    public String simpleFault(String value) throws Exception {
       TestFault fault = new TestFault(value);
       throw fault;
    }


}