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.cxf.systest.jms;
19:
20: import javax.annotation.Resource;
21: import javax.jws.WebService;
22: import javax.xml.ws.WebServiceContext;
23: import javax.xml.ws.handler.MessageContext;
24:
25: import org.apache.cxf.hello_world_jms.BadRecordLitFault;
26: import org.apache.cxf.hello_world_jms.HelloWorldPortType;
27: import org.apache.cxf.hello_world_jms.NoSuchCodeLitFault;
28: import org.apache.cxf.hello_world_jms.types.BadRecordLit;
29: import org.apache.cxf.hello_world_jms.types.ErrorCode;
30: import org.apache.cxf.hello_world_jms.types.NoSuchCodeLit;
31: import org.apache.cxf.hello_world_jms.types.TestRpcLitFaultResponse;
32: import org.apache.cxf.transport.jms.JMSConstants;
33: import org.apache.cxf.transport.jms.JMSMessageHeadersType;
34: import org.apache.cxf.transport.jms.JMSPropertyType;
35:
36: @WebService(serviceName="HelloWorldService",portName="HelloWorldPort",endpointInterface="org.apache.cxf.hello_world_jms.HelloWorldPortType",targetNamespace="http://cxf.apache.org/hello_world_jms",wsdlLocation="testutils/jms_test.wsdl")
37: public class GreeterImplTwoWayJMS implements HelloWorldPortType {
38: @Resource
39: protected WebServiceContext wsContext;
40:
41: public String greetMe(String me) {
42: MessageContext mc = wsContext.getMessageContext();
43: JMSMessageHeadersType headers = (JMSMessageHeadersType) mc
44: .get(JMSConstants.JMS_SERVER_REQUEST_HEADERS);
45: System.out.println("get the message headers JMSCorrelationID"
46: + headers.getJMSCorrelationID());
47: System.out.println("Reached here :" + me);
48:
49: // set reply header custom property
50: JMSPropertyType testProperty = new JMSPropertyType();
51: testProperty.setName("Test_Prop");
52: testProperty.setValue("some return value " + me);
53:
54: System.out
55: .println("found property in request headers at index: "
56: + headers.getProperty().indexOf(testProperty));
57:
58: JMSMessageHeadersType responseHeaders = (JMSMessageHeadersType) mc
59: .get(JMSConstants.JMS_SERVER_RESPONSE_HEADERS);
60: responseHeaders.getProperty().add(testProperty);
61:
62: return "Hello " + me;
63: }
64:
65: public String sayHi() {
66: return "Bonjour";
67: }
68:
69: public void greetMeOneWay(String requestType) {
70: System.out.println("********* greetMeOneWay: " + requestType);
71: }
72:
73: public TestRpcLitFaultResponse testRpcLitFault(String faultType)
74: throws BadRecordLitFault, NoSuchCodeLitFault {
75: BadRecordLit badRecord = new BadRecordLit();
76: badRecord.setReason("BadRecordLitFault");
77: if (faultType.equals(BadRecordLitFault.class.getSimpleName())) {
78: throw new BadRecordLitFault("TestBadRecordLit", badRecord);
79: }
80: if (faultType.equals(NoSuchCodeLitFault.class.getSimpleName())) {
81: ErrorCode ec = new ErrorCode();
82: ec.setMajor((short) 1);
83: ec.setMinor((short) 1);
84: NoSuchCodeLit nscl = new NoSuchCodeLit();
85: nscl.setCode(ec);
86: throw new NoSuchCodeLitFault("TestNoSuchCodeLit", nscl);
87: }
88:
89: return new TestRpcLitFaultResponse();
90: }
91:
92: }
|