28 import com.sun.xml.internal.ws.addressing.model.InvalidAddressingHeaderException; |
28 import com.sun.xml.internal.ws.addressing.model.InvalidAddressingHeaderException; |
29 import com.sun.xml.internal.ws.addressing.model.MissingAddressingHeaderException; |
29 import com.sun.xml.internal.ws.addressing.model.MissingAddressingHeaderException; |
30 import com.sun.xml.internal.ws.api.SOAPVersion; |
30 import com.sun.xml.internal.ws.api.SOAPVersion; |
31 import com.sun.xml.internal.ws.api.WSBinding; |
31 import com.sun.xml.internal.ws.api.WSBinding; |
32 import com.sun.xml.internal.ws.api.addressing.AddressingVersion; |
32 import com.sun.xml.internal.ws.api.addressing.AddressingVersion; |
33 import com.sun.xml.internal.ws.api.message.Message; |
33 import com.sun.xml.internal.ws.api.message.AddressingUtils; |
34 import com.sun.xml.internal.ws.api.message.Packet; |
34 import com.sun.xml.internal.ws.api.message.Packet; |
35 import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation; |
35 import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation; |
36 import com.sun.xml.internal.ws.api.model.wsdl.WSDLFault; |
36 import com.sun.xml.internal.ws.api.model.wsdl.WSDLFault; |
37 import com.sun.xml.internal.ws.api.model.wsdl.WSDLOperation; |
37 import com.sun.xml.internal.ws.api.model.wsdl.WSDLOperation; |
38 import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput; |
38 import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput; |
39 import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort; |
39 import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort; |
40 import com.sun.xml.internal.ws.api.model.SEIModel; |
40 import com.sun.xml.internal.ws.api.model.SEIModel; |
41 import com.sun.xml.internal.ws.api.model.JavaMethod; |
41 import com.sun.xml.internal.ws.api.model.JavaMethod; |
|
42 import com.sun.xml.internal.ws.api.model.WSDLOperationMapping; |
42 import com.sun.xml.internal.ws.model.wsdl.WSDLOperationImpl; |
43 import com.sun.xml.internal.ws.model.wsdl.WSDLOperationImpl; |
43 import com.sun.xml.internal.ws.model.JavaMethodImpl; |
44 import com.sun.xml.internal.ws.model.JavaMethodImpl; |
44 import com.sun.xml.internal.ws.model.CheckedExceptionImpl; |
45 import com.sun.xml.internal.ws.model.CheckedExceptionImpl; |
45 import com.sun.istack.internal.Nullable; |
46 import com.sun.istack.internal.Nullable; |
46 import org.w3c.dom.Element; |
47 import org.w3c.dom.Element; |
73 public String getFaultAction(Packet requestPacket, Packet responsePacket) { |
73 public String getFaultAction(Packet requestPacket, Packet responsePacket) { |
74 String action = null; |
74 String action = null; |
75 if(seiModel != null) { |
75 if(seiModel != null) { |
76 action = getFaultActionFromSEIModel(requestPacket,responsePacket); |
76 action = getFaultActionFromSEIModel(requestPacket,responsePacket); |
77 } |
77 } |
78 if(action != null) |
78 if (action != null) { |
79 return action; |
79 return action; |
80 else |
80 } else { |
81 action = addVer.getDefaultFaultAction(); |
81 action = addVer.getDefaultFaultAction(); |
|
82 } |
82 if (wsdlPort != null) { |
83 if (wsdlPort != null) { |
83 QName wsdlOp = requestPacket.getWSDLOperation(); |
84 WSDLOperationMapping wsdlOp = requestPacket.getWSDLOperationMapping(); |
84 if (wsdlOp != null) { |
85 if (wsdlOp != null) { |
85 WSDLBoundOperation wbo = wsdlPort.getBinding().get(wsdlOp); |
86 WSDLBoundOperation wbo = wsdlOp.getWSDLBoundOperation(); |
86 return getFaultAction(wbo, responsePacket); |
87 return getFaultAction(wbo, responsePacket); |
87 } |
88 } |
88 } |
89 } |
89 return action; |
90 return action; |
90 } |
91 } |
91 |
92 |
92 String getFaultActionFromSEIModel(Packet requestPacket, Packet responsePacket) { |
93 String getFaultActionFromSEIModel(Packet requestPacket, Packet responsePacket) { |
93 String action = null; |
94 String action = null; |
94 if (seiModel == null || wsdlPort == null) |
95 if (seiModel == null || wsdlPort == null) { |
95 return action; |
96 return action; |
|
97 } |
96 |
98 |
97 try { |
99 try { |
98 SOAPMessage sm = responsePacket.getMessage().copy().readAsSOAPMessage(); |
100 SOAPMessage sm = responsePacket.getMessage().copy().readAsSOAPMessage(); |
99 if (sm == null) |
101 if (sm == null) { |
100 return action; |
102 return action; |
101 |
103 } |
102 if (sm.getSOAPBody() == null) |
104 |
103 return action; |
105 if (sm.getSOAPBody() == null) { |
104 |
106 return action; |
105 if (sm.getSOAPBody().getFault() == null) |
107 } |
106 return action; |
108 |
|
109 if (sm.getSOAPBody().getFault() == null) { |
|
110 return action; |
|
111 } |
107 |
112 |
108 Detail detail = sm.getSOAPBody().getFault().getDetail(); |
113 Detail detail = sm.getSOAPBody().getFault().getDetail(); |
109 if (detail == null) |
114 if (detail == null) { |
110 return action; |
115 return action; |
|
116 } |
111 |
117 |
112 String ns = detail.getFirstChild().getNamespaceURI(); |
118 String ns = detail.getFirstChild().getNamespaceURI(); |
113 String name = detail.getFirstChild().getLocalName(); |
119 String name = detail.getFirstChild().getLocalName(); |
114 |
120 |
115 QName wsdlOp = requestPacket.getWSDLOperation(); |
121 WSDLOperationMapping wsdlOp = requestPacket.getWSDLOperationMapping(); |
116 JavaMethodImpl jm = (JavaMethodImpl) seiModel.getJavaMethodForWsdlOperation(wsdlOp); |
122 JavaMethodImpl jm = (wsdlOp != null) ? (JavaMethodImpl)wsdlOp.getJavaMethod() : null; |
117 if (jm != null) { |
123 if (jm != null) { |
118 for (CheckedExceptionImpl ce : jm.getCheckedExceptions()) { |
124 for (CheckedExceptionImpl ce : jm.getCheckedExceptions()) { |
119 if (ce.getDetailType().tagName.getLocalPart().equals(name) && |
125 if (ce.getDetailType().tagName.getLocalPart().equals(name) && |
120 ce.getDetailType().tagName.getNamespaceURI().equals(ns)) { |
126 ce.getDetailType().tagName.getNamespaceURI().equals(ns)) { |
121 return ce.getFaultAction(); |
127 return ce.getFaultAction(); |
127 throw new WebServiceException(e); |
133 throw new WebServiceException(e); |
128 } |
134 } |
129 } |
135 } |
130 |
136 |
131 String getFaultAction(@Nullable WSDLBoundOperation wbo, Packet responsePacket) { |
137 String getFaultAction(@Nullable WSDLBoundOperation wbo, Packet responsePacket) { |
132 String action = responsePacket.getMessage().getHeaders().getAction(addVer, soapVer); |
138 String action = AddressingUtils.getAction(responsePacket.getMessage().getHeaders(), addVer, soapVer); |
133 if (action != null) |
139 if (action != null) { |
134 return action; |
140 return action; |
|
141 } |
135 |
142 |
136 action = addVer.getDefaultFaultAction(); |
143 action = addVer.getDefaultFaultAction(); |
137 if (wbo == null) |
144 if (wbo == null) { |
138 return action; |
145 return action; |
|
146 } |
139 |
147 |
140 try { |
148 try { |
141 SOAPMessage sm = responsePacket.getMessage().copy().readAsSOAPMessage(); |
149 SOAPMessage sm = responsePacket.getMessage().copy().readAsSOAPMessage(); |
142 if (sm == null) |
150 if (sm == null) { |
143 return action; |
151 return action; |
144 |
152 } |
145 if (sm.getSOAPBody() == null) |
153 |
146 return action; |
154 if (sm.getSOAPBody() == null) { |
147 |
155 return action; |
148 if (sm.getSOAPBody().getFault() == null) |
156 } |
149 return action; |
157 |
|
158 if (sm.getSOAPBody().getFault() == null) { |
|
159 return action; |
|
160 } |
150 |
161 |
151 Detail detail = sm.getSOAPBody().getFault().getDetail(); |
162 Detail detail = sm.getSOAPBody().getFault().getDetail(); |
152 if (detail == null) |
163 if (detail == null) { |
153 return action; |
164 return action; |
|
165 } |
154 |
166 |
155 String ns = detail.getFirstChild().getNamespaceURI(); |
167 String ns = detail.getFirstChild().getNamespaceURI(); |
156 String name = detail.getFirstChild().getLocalName(); |
168 String name = detail.getFirstChild().getLocalName(); |
157 |
169 |
158 WSDLOperation o = wbo.getOperation(); |
170 WSDLOperation o = wbo.getOperation(); |
159 |
171 |
160 WSDLFault fault = o.getFault(new QName(ns, name)); |
172 WSDLFault fault = o.getFault(new QName(ns, name)); |
161 if (fault == null) |
173 if (fault == null) { |
162 return action; |
174 return action; |
163 |
175 } |
164 WSDLOperationImpl impl = (WSDLOperationImpl)o; |
176 |
165 action = fault.getAction(); |
177 action = fault.getAction(); |
166 |
178 |
167 return action; |
179 return action; |
168 } catch (SOAPException e) { |
180 } catch (SOAPException e) { |
169 throw new WebServiceException(e); |
181 throw new WebServiceException(e); |
192 * @param packet |
204 * @param packet |
193 * @return input Action |
205 * @return input Action |
194 */ |
206 */ |
195 public String getEffectiveInputAction(Packet packet) { |
207 public String getEffectiveInputAction(Packet packet) { |
196 //non-default SOAPAction beomes wsa:action |
208 //non-default SOAPAction beomes wsa:action |
197 if(packet.soapAction != null && !packet.soapAction.equals("")) |
209 if(packet.soapAction != null && !packet.soapAction.equals("")) { |
198 return packet.soapAction; |
210 return packet.soapAction; |
199 String action = null; |
211 } |
|
212 String action; |
200 |
213 |
201 if (wsdlPort != null) { |
214 if (wsdlPort != null) { |
202 QName wsdlOp = packet.getWSDLOperation(); |
215 WSDLOperationMapping wsdlOp = packet.getWSDLOperationMapping(); |
203 if (wsdlOp != null) { |
216 if (wsdlOp != null) { |
204 WSDLBoundOperation wbo = wsdlPort.getBinding().get(wsdlOp); |
217 WSDLBoundOperation wbo = wsdlOp.getWSDLBoundOperation(); |
205 WSDLOperation op = wbo.getOperation(); |
218 WSDLOperation op = wbo.getOperation(); |
206 action = op.getInput().getAction(); |
219 action = op.getInput().getAction(); |
207 } else |
220 } else { |
208 action = packet.soapAction; |
221 action = packet.soapAction; |
|
222 } |
209 } else { |
223 } else { |
210 action = packet.soapAction; |
224 action = packet.soapAction; |
211 } |
225 } |
212 return action; |
226 return action; |
213 } |
227 } |
214 |
228 |
215 public boolean isInputActionDefault(Packet packet) { |
229 public boolean isInputActionDefault(Packet packet) { |
216 if (wsdlPort == null) |
230 if (wsdlPort == null) { |
217 return false; |
231 return false; |
218 QName wsdlOp = packet.getWSDLOperation(); |
232 } |
219 if(wsdlOp == null) |
233 WSDLOperationMapping wsdlOp = packet.getWSDLOperationMapping(); |
|
234 if(wsdlOp == null) { |
220 return false; |
235 return false; |
221 WSDLBoundOperation wbo = wsdlPort.getBinding().get(wsdlOp); |
236 } |
|
237 WSDLBoundOperation wbo = wsdlOp.getWSDLBoundOperation(); |
222 WSDLOperation op = wbo.getOperation(); |
238 WSDLOperation op = wbo.getOperation(); |
223 return ((WSDLOperationImpl) op).getInput().isDefaultAction(); |
239 return ((WSDLOperationImpl) op).getInput().isDefaultAction(); |
224 |
240 |
225 } |
241 } |
226 |
242 |
227 public String getSOAPAction(Packet packet) { |
243 public String getSOAPAction(Packet packet) { |
228 String action = ""; |
244 String action = ""; |
229 |
245 |
230 if (packet == null || packet.getMessage() == null) |
246 if (packet == null || packet.getMessage() == null) { |
231 return action; |
247 return action; |
232 |
248 } |
233 if (wsdlPort == null) |
249 |
234 return action; |
250 if (wsdlPort == null) { |
235 |
251 return action; |
236 QName opName = packet.getWSDLOperation(); |
252 } |
237 if(opName == null) |
253 |
238 return action; |
254 WSDLOperationMapping wsdlOp = packet.getWSDLOperationMapping(); |
239 |
255 if (wsdlOp == null) { |
240 WSDLBoundOperation op = wsdlPort.getBinding().get(opName); |
256 return action; |
|
257 } |
|
258 |
|
259 WSDLBoundOperation op = wsdlOp.getWSDLBoundOperation(); |
241 action = op.getSOAPAction(); |
260 action = op.getSOAPAction(); |
242 return action; |
261 return action; |
243 } |
262 } |
244 |
263 |
245 public String getOutputAction(Packet packet) { |
264 public String getOutputAction(Packet packet) { |
246 //String action = AddressingVersion.UNSET_OUTPUT_ACTION; |
265 //String action = AddressingVersion.UNSET_OUTPUT_ACTION; |
247 String action = null; |
266 String action = null; |
248 QName wsdlOp = packet.getWSDLOperation(); |
267 WSDLOperationMapping wsdlOp = packet.getWSDLOperationMapping(); |
249 if (wsdlOp != null) { |
268 if (wsdlOp != null) { |
250 if (seiModel != null) { |
269 JavaMethod javaMethod = wsdlOp.getJavaMethod(); |
251 JavaMethodImpl jm = (JavaMethodImpl) seiModel.getJavaMethodForWsdlOperation(wsdlOp); |
270 if (javaMethod != null) { |
|
271 JavaMethodImpl jm = (JavaMethodImpl) javaMethod; |
252 if (jm != null && jm.getOutputAction() != null && !jm.getOutputAction().equals("")) { |
272 if (jm != null && jm.getOutputAction() != null && !jm.getOutputAction().equals("")) { |
253 return jm.getOutputAction(); |
273 return jm.getOutputAction(); |
254 } |
274 } |
255 } |
275 } |
256 if (wsdlPort != null) { |
276 WSDLBoundOperation wbo = wsdlOp.getWSDLBoundOperation(); |
257 WSDLBoundOperation wbo = wsdlPort.getBinding().get(wsdlOp); |
277 if (wbo != null) return getOutputAction(wbo); |
258 return getOutputAction(wbo); |
|
259 } |
|
260 } |
278 } |
261 return action; |
279 return action; |
262 } |
280 } |
263 |
281 |
264 String getOutputAction(@Nullable WSDLBoundOperation wbo) { |
282 String getOutputAction(@Nullable WSDLBoundOperation wbo) { |
265 String action = AddressingVersion.UNSET_OUTPUT_ACTION; |
283 String action = AddressingVersion.UNSET_OUTPUT_ACTION; |
266 if (wbo != null) { |
284 if (wbo != null) { |
267 WSDLOutput op = wbo.getOperation().getOutput(); |
285 WSDLOutput op = wbo.getOperation().getOutput(); |
268 if (op != null) |
286 if (op != null) { |
269 action = op.getAction(); |
287 action = op.getAction(); |
|
288 } |
270 } |
289 } |
271 return action; |
290 return action; |
272 } |
291 } |
273 |
292 |
274 public SOAPFault createInvalidAddressingHeaderFault(InvalidAddressingHeaderException e, AddressingVersion av) { |
293 public SOAPFault createInvalidAddressingHeaderFault(InvalidAddressingHeaderException e, AddressingVersion av) { |