01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.geronimo.test;
19:
20: import javax.ejb.Remote;
21: import javax.ejb.Stateless;
22: import javax.jws.WebService;
23: import javax.jws.HandlerChain;
24: import javax.jws.soap.SOAPBinding;
25: import javax.xml.namespace.QName;
26: import javax.xml.soap.SOAPException;
27: import javax.xml.soap.SOAPFactory;
28: import javax.xml.soap.SOAPFault;
29: import javax.xml.ws.soap.SOAPFaultException;
30:
31: @WebService
32: @Stateless(mappedName="JAXWSBean")
33: @Remote(JAXWSGreeter.class)
34: @HandlerChain(file="handlers.xml")
35: @SOAPBinding(style=SOAPBinding.Style.RPC,use=SOAPBinding.Use.LITERAL,parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)
36: public class JAXWSBean implements JAXWSGreeter {
37:
38: public String greetMe(String me) {
39: System.out.println("i'm a ejb ws: " + me);
40: if (!"foo bar".equals(me)) {
41: throw new RuntimeException("Wrong parameter");
42: }
43: return "Hello " + me;
44: }
45:
46: public void greetMeFault(String me) {
47: System.out.println("generate SOAP fault");
48: SOAPFault fault = null;
49: try {
50: fault = SOAPFactory.newInstance().createFault();
51: fault.setFaultCode(new QName("http://foo", "MyFaultCode"));
52: fault.setFaultString("my error");
53: fault.setFaultActor("my actor");
54: } catch (SOAPException ex) {
55: throw new RuntimeException(ex);
56: }
57:
58: throw new SOAPFaultException(fault);
59: }
60:
61: }
|