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: */package org.apache.hello_world_soap_http;
019:
020: import java.util.HashMap;
021: import java.util.Map;
022: import java.util.logging.Logger;
023: import javax.annotation.Resource;
024: import javax.jws.HandlerChain;
025: import javax.jws.WebMethod;
026: import javax.jws.WebParam;
027: import javax.jws.WebResult;
028: import javax.xml.ws.RequestWrapper;
029: import javax.xml.ws.ResponseWrapper;
030: import javax.xml.ws.WebServiceContext;
031:
032: @javax.jws.WebService(name="Greeter",serviceName="SOAPService",targetNamespace="http://apache.org/hello_world_soap_http")
033: @HandlerChain(name="TestHandlerChain",file="handlers.xml")
034: public class AnnotatedGreeterImpl {
035:
036: private static final Logger LOG = Logger
037: .getLogger(AnnotatedGreeterImpl.class.getName());
038:
039: @Resource
040: private int foo;
041:
042: private WebServiceContext context;
043:
044: private final Map<String, Integer> invocationCount = new HashMap<String, Integer>();
045:
046: public AnnotatedGreeterImpl() {
047: invocationCount.put("sayHi", 0);
048: invocationCount.put("greetMe", 0);
049: invocationCount.put("overloadedSayHi", 0);
050: }
051:
052: public int getInvocationCount(String method) {
053: if (invocationCount.containsKey(method)) {
054: return invocationCount.get(method).intValue();
055: } else {
056: System.out.println("No invocation count for method: "
057: + method);
058: return 0;
059: }
060: }
061:
062: /**
063: * overloaded method - present for test purposes
064: */
065: @WebMethod(operationName="sayHiOverloaded")
066: @WebResult(name="responseType2",targetNamespace="http://apache.org/hello_world_soap_http/types")
067: @RequestWrapper(className="org.apache.hello_world_soap_http.types.SayHi2",localName="sayHi2",targetNamespace="http://apache.org/hello_world_soap_http/types")
068: @ResponseWrapper(className="org.apache.hello_world_soap_http.types.SayHiResponse2",localName="sayHiResponse2",targetNamespace="http://apache.org/hello_world_soap_http/types")
069: public String sayHi(String me) {
070: incrementInvocationCount("overloadedSayHi");
071: return "Hi " + me + "!";
072: }
073:
074: @WebMethod
075: @WebResult(name="responseType",targetNamespace="http://apache.org/hello_world_soap_http/types")
076: @RequestWrapper(className="org.apache.hello_world_soap_http.types.SayHi",localName="sayHi",targetNamespace="http://apache.org/hello_world_soap_http/types")
077: @ResponseWrapper(className="org.apache.hello_world_soap_http.types.SayHiResponse",localName="sayHiResponse",targetNamespace="http://apache.org/hello_world_soap_http/types")
078: public String sayHi() {
079: incrementInvocationCount("sayHi");
080: return "Hi";
081: }
082:
083: @WebMethod
084: @WebResult(name="responseType",targetNamespace="http://apache.org/hello_world_soap_http/types")
085: @RequestWrapper(className="org.apache.hello_world_soap_http.types.GreetMe",localName="greetMe",targetNamespace="http://apache.org/hello_world_soap_http/types")
086: @ResponseWrapper(className="org.apache.hello_world_soap_http.types.GreetMeResponse",localName="greetMeResponse",targetNamespace="http://apache.org/hello_world_soap_http/types")
087: public String greetMe(String me) {
088: incrementInvocationCount("greetMe");
089: return "Bonjour " + me + "!";
090: }
091:
092: @WebMethod
093: @RequestWrapper(className="org.apache.hello_world_soap_http.types.GreetMeOneWay",localName="greetMeOneWay",targetNamespace="http://apache.org/hello_world_soap_http/types")
094: public void greetMeOneWay(String me) {
095: incrementInvocationCount("greetMeOneWay");
096: System.out.println("Hello there " + me);
097: System.out.println("That was OneWay to say hello");
098: }
099:
100: public void testDocLitFault(String faultType)
101: throws BadRecordLitFault, NoSuchCodeLitFault {
102: }
103:
104: @Resource
105: public void setContext(WebServiceContext ctx) {
106: context = ctx;
107: }
108:
109: public WebServiceContext getContext() {
110: return context;
111: }
112:
113: @WebMethod(operationName="PutLastTradedPrice")
114: public void putLastTradedPriceAsync(
115: @WebParam(name="body",partName="body")
116: String body) {
117: //Complete
118: }
119:
120: @WebMethod(operationName="PutLastTradedPrice")
121: public void putLastTradedPrice(
122: @WebParam(name="body",partName="body")
123: String body) {
124: //Complete
125: }
126:
127: /**
128: * stop eclipse from whinging
129: */
130: public int getFoo() {
131: return foo;
132: }
133:
134: private void incrementInvocationCount(String method) {
135: LOG.info("Executing " + method);
136: int n = invocationCount.get(method);
137: invocationCount.put(method, n + 1);
138: }
139:
140: }
|