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.cxf.systest.ws.addressing;
019:
020: import java.util.concurrent.Future;
021:
022: import javax.annotation.Resource;
023: import javax.jws.WebService;
024: import javax.xml.ws.AsyncHandler;
025: import javax.xml.ws.Response;
026: import javax.xml.ws.WebServiceContext;
027:
028: import org.apache.cxf.ws.addressing.AddressingProperties;
029: import org.apache.hello_world_soap_http.BadRecordLitFault;
030: import org.apache.hello_world_soap_http.Greeter;
031: import org.apache.hello_world_soap_http.NoSuchCodeLitFault;
032: import org.apache.hello_world_soap_http.types.BareDocumentResponse;
033: import org.apache.hello_world_soap_http.types.ErrorCode;
034: import org.apache.hello_world_soap_http.types.GreetMeLaterResponse;
035: import org.apache.hello_world_soap_http.types.GreetMeResponse;
036: import org.apache.hello_world_soap_http.types.GreetMeSometimeResponse;
037: import org.apache.hello_world_soap_http.types.NoSuchCodeLit;
038: import org.apache.hello_world_soap_http.types.SayHiResponse;
039: import org.apache.hello_world_soap_http.types.TestDocLitFaultResponse;
040: import org.apache.hello_world_soap_http.types.TestNillableResponse;
041:
042: import static org.apache.cxf.ws.addressing.JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND;
043:
044: @WebService(serviceName="SOAPServiceAddressing",portName="SoapPort",endpointInterface="org.apache.hello_world_soap_http.Greeter",targetNamespace="http://apache.org/hello_world_soap_http",wsdlLocation="testutils/hello_world.wsdl")
045: public class GreeterImpl implements Greeter {
046: VerificationCache verificationCache;
047:
048: /**
049: * Injectable context.
050: */
051: @Resource
052: private WebServiceContext context;
053:
054: public String greetMe(String me) {
055: System.out.println("\n\n*** GreetMe called with: " + me
056: + "***\n\n");
057: verifyMAPs();
058: return "Hello " + me;
059: }
060:
061: public String greetMeLater(long delay) {
062: System.out.println("\n\n*** GreetMeLater called with: " + delay
063: + "***\n\n");
064: if (delay > 0) {
065: try {
066: Thread.sleep(delay);
067: } catch (InterruptedException ex) {
068: // ignore
069: }
070: }
071: verifyMAPs();
072: return "Hello, finally";
073: }
074:
075: public void greetMeOneWay(String requestType) {
076: System.out.println("\n\n*** GreetMeOneWay called with: "
077: + requestType + "***\n\n");
078: verifyMAPs();
079: }
080:
081: public String sayHi() {
082: verifyMAPs();
083: return "Bonjour";
084: }
085:
086: public void testDocLitFault(String faultType)
087: throws BadRecordLitFault, NoSuchCodeLitFault {
088: verifyMAPs();
089: if (faultType.equals(BadRecordLitFault.class.getSimpleName())) {
090: throw new BadRecordLitFault("TestBadRecordLit",
091: "BadRecordLitFault");
092: }
093: if (faultType.equals(NoSuchCodeLitFault.class.getSimpleName())) {
094: ErrorCode ec = new ErrorCode();
095: ec.setMajor((short) 1);
096: ec.setMinor((short) 1);
097: NoSuchCodeLit nscl = new NoSuchCodeLit();
098: nscl.setCode(ec);
099: throw new NoSuchCodeLitFault("TestNoSuchCodeLit", nscl);
100: }
101: }
102:
103: public BareDocumentResponse testDocLitBare(String in) {
104: BareDocumentResponse res = new BareDocumentResponse();
105: res.setCompany("Celtix");
106: res.setId(1);
107: return res;
108: }
109:
110: private void verifyMAPs() {
111: if (context.getMessageContext() != null) {
112: String property = SERVER_ADDRESSING_PROPERTIES_INBOUND;
113: AddressingProperties maps = (AddressingProperties) context
114: .getMessageContext().get(property);
115: verificationCache.put(MAPTest.verifyMAPs(maps, this ));
116: }
117: }
118:
119: public String greetMeSometime(String me) {
120: return "How are you " + me;
121: }
122:
123: public Future<?> greetMeSometimeAsync(String requestType,
124: AsyncHandler<GreetMeSometimeResponse> asyncHandler) {
125: return null;
126: /*not called */
127: }
128:
129: public Response<GreetMeSometimeResponse> greetMeSometimeAsync(
130: String requestType) {
131: return null;
132: /*not called */
133: }
134:
135: public Response<TestDocLitFaultResponse> testDocLitFaultAsync(
136: String faultType) {
137: return null;
138: /*not called */
139: }
140:
141: public Future<?> testDocLitFaultAsync(String faultType,
142: AsyncHandler ah) {
143: return null;
144: /*not called */
145: }
146:
147: public Future<?> testDocLitBareAsync(String bare, AsyncHandler ah) {
148: return null;
149: /* not called */
150: }
151:
152: public Response<BareDocumentResponse> testDocLitBareAsync(
153: String bare) {
154: return null;
155: /* not called */
156: }
157:
158: public Future<?> greetMeAsync(String requestType,
159: AsyncHandler<GreetMeResponse> asyncHandler) {
160: return null;
161: /*not called */
162: }
163:
164: public Response<GreetMeResponse> greetMeAsync(String requestType) {
165: return null;
166: /*not called */
167: }
168:
169: public Future<?> greetMeLaterAsync(long requestType,
170: AsyncHandler<GreetMeLaterResponse> asyncHandler) {
171: return null;
172: /*not called */
173: }
174:
175: public Response<GreetMeLaterResponse> greetMeLaterAsync(
176: long requestType) {
177: return null;
178: /*not called */
179: }
180:
181: public Future<?> sayHiAsync(AsyncHandler<SayHiResponse> asyncHandler) {
182: return null;
183: /*not called */
184: }
185:
186: public Response<SayHiResponse> sayHiAsync() {
187: return null;
188: /*not called */
189: }
190:
191: public String testNillable(String nillElem, int intElem) {
192: // TODO Auto-generated method stub
193: return null;
194: }
195:
196: public Response<TestNillableResponse> testNillableAsync(
197: String nillElem, int intElem) {
198: return null;
199: }
200:
201: public Future<?> testNillableAsync(String nillElem, int intElem,
202: AsyncHandler<TestNillableResponse> asyncHandler) {
203: return null;
204: }
205:
206: }
|