1 /**
2 *
3 * Copyright 2003-2004 The Apache Software Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.geronimo.axis.client;
18
19 import java.io.Serializable;
20 import java.rmi.RemoteException;
21
22 import javax.xml.namespace.QName;
23
24 import org.apache.axis.description.OperationDesc;
25 import org.apache.axis.description.FaultDesc;
26 import org.apache.axis.client.Call;
27 import org.apache.axis.soap.SOAPConstants;
28 import org.apache.axis.AxisFault;
29 import net.sf.cglib.core.Signature;
30
31 /**
32 * @version $Rev: 356022 $ $Date: 2005-12-11 12:58:34 -0800 (Sun, 11 Dec 2005) $
33 */
34 public class OperationInfo implements Serializable {
35
36 private final OperationDesc operationDesc;
37 private final boolean useSOAPAction;
38 private final String soapActionURI;
39 private final SOAPConstants soapVersion;
40 private final QName operationName;
41 private final String methodName;
42 private final String methodDesc;
43
44 public OperationInfo(OperationDesc operationDesc, boolean useSOAPAction, String soapActionURI, SOAPConstants soapVersion, QName operationName, String methodName, String methodDesc) {
45 this.operationDesc = operationDesc;
46 this.useSOAPAction = useSOAPAction;
47 this.soapActionURI = soapActionURI;
48 this.soapVersion = soapVersion;
49 this.operationName = operationName;
50 this.methodName = methodName;
51 this.methodDesc = methodDesc;
52 }
53
54 public Signature getSignature() {
55 return new Signature(methodName, methodDesc);
56 }
57
58 public OperationDesc getOperationDesc() {
59 return operationDesc;
60 }
61
62 public boolean isUseSOAPAction() {
63 return useSOAPAction;
64 }
65
66 public String getSoapActionURI() {
67 return soapActionURI;
68 }
69
70 public SOAPConstants getSoapVersion() {
71 return soapVersion;
72 }
73
74 public QName getOperationName() {
75 return operationName;
76 }
77
78 public void prepareCall(Call call) {
79 call.setOperation(operationDesc);
80 call.setUseSOAPAction(useSOAPAction);
81 call.setSOAPActionURI(soapActionURI);
82 call.setSOAPVersion(soapVersion);
83 call.setOperationName(operationName);
84
85 call.setOperationStyle(operationDesc.getStyle());
86 call.setOperationUse(operationDesc.getUse());
87 }
88
89 public Throwable unwrapFault(RemoteException re) {
90 if (re instanceof AxisFault && re.getCause() != null) {
91 Throwable t = re.getCause();
92 if (operationDesc.getFaultByClass(t.getClass()) != null) {
93 return t;
94 }
95 }
96 return re;
97 }
98 }