src/share/jaxws_classes/com/sun/tools/internal/ws/wsdl/parser/SOAPExtensionHandler.java

changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 637
9c07ef4934dd
equal deleted inserted replaced
366:8c0b6bccfe47 368:0989ad8c0860
1 /* 1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
230 parent.addExtension(body); 230 parent.addExtension(body);
231 context.pop(); 231 context.pop();
232 // context.fireDoneParsingEntity(getBodyQName(), body); 232 // context.fireDoneParsingEntity(getBodyQName(), body);
233 return true; 233 return true;
234 } else if (XmlUtil.matchesTagNS(e, getHeaderQName())) { 234 } else if (XmlUtil.matchesTagNS(e, getHeaderQName())) {
235 context.push(); 235 return handleHeaderElement(parent, e, context);
236 context.registerNamespaces(e);
237
238 SOAPHeader header = new SOAPHeader(context.getLocation(e));
239
240 String use = XmlUtil.getAttributeOrNull(e, Constants.ATTR_USE);
241 if (use != null) {
242 if (use.equals(Constants.ATTRVALUE_LITERAL)) {
243 header.setUse(SOAPUse.LITERAL);
244 } else if (use.equals(Constants.ATTRVALUE_ENCODED)) {
245 header.setUse(SOAPUse.ENCODED);
246 } else {
247 Util.fail(
248 "parsing.invalidAttributeValue",
249 Constants.ATTR_USE,
250 use);
251 }
252 }
253
254 String namespace =
255 XmlUtil.getAttributeOrNull(e, Constants.ATTR_NAMESPACE);
256 if (namespace != null) {
257 header.setNamespace(namespace);
258 }
259
260 String encodingStyle =
261 XmlUtil.getAttributeOrNull(e, Constants.ATTR_ENCODING_STYLE);
262 if (encodingStyle != null) {
263 header.setEncodingStyle(encodingStyle);
264 }
265
266 String part = XmlUtil.getAttributeOrNull(e, Constants.ATTR_PART);
267 if (part != null) {
268 header.setPart(part);
269 }
270
271 String messageAttr =
272 XmlUtil.getAttributeOrNull(e, Constants.ATTR_MESSAGE);
273 if (messageAttr != null) {
274 header.setMessage(context.translateQualifiedName(context.getLocation(e), messageAttr));
275 }
276
277 for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
278 Element e2 = Util.nextElement(iter);
279 if (e2 == null)
280 break;
281
282 if (XmlUtil
283 .matchesTagNS(e2, getHeaderfaultQName())) {
284 context.push();
285 context.registerNamespaces(e);
286
287 SOAPHeaderFault headerfault = new SOAPHeaderFault(context.getLocation(e));
288
289 String use2 =
290 XmlUtil.getAttributeOrNull(e2, Constants.ATTR_USE);
291 if (use2 != null) {
292 if (use2.equals(Constants.ATTRVALUE_LITERAL)) {
293 headerfault.setUse(SOAPUse.LITERAL);
294 } else if (use.equals(Constants.ATTRVALUE_ENCODED)) {
295 headerfault.setUse(SOAPUse.ENCODED);
296 } else {
297 Util.fail(
298 "parsing.invalidAttributeValue",
299 Constants.ATTR_USE,
300 use2);
301 }
302 }
303
304 String namespace2 =
305 XmlUtil.getAttributeOrNull(
306 e2,
307 Constants.ATTR_NAMESPACE);
308 if (namespace2 != null) {
309 headerfault.setNamespace(namespace2);
310 }
311
312 String encodingStyle2 =
313 XmlUtil.getAttributeOrNull(
314 e2,
315 Constants.ATTR_ENCODING_STYLE);
316 if (encodingStyle2 != null) {
317 headerfault.setEncodingStyle(encodingStyle2);
318 }
319
320 String part2 =
321 XmlUtil.getAttributeOrNull(e2, Constants.ATTR_PART);
322 if (part2 != null) {
323 headerfault.setPart(part2);
324 }
325
326 String messageAttr2 =
327 XmlUtil.getAttributeOrNull(e2, Constants.ATTR_MESSAGE);
328 if (messageAttr2 != null) {
329 headerfault.setMessage(
330 context.translateQualifiedName(context.getLocation(e2), messageAttr2));
331 }
332
333 header.add(headerfault);
334 context.pop();
335 } else {
336 Util.fail(
337 "parsing.invalidElement",
338 e2.getTagName(),
339 e2.getNamespaceURI());
340 }
341 }
342
343 parent.addExtension(header);
344 context.pop();
345 context.fireDoneParsingEntity(getHeaderQName(), header);
346 return true;
347 } else { 236 } else {
348 Util.fail( 237 Util.fail("parsing.invalidExtensionElement", e.getTagName(), e.getNamespaceURI());
349 "parsing.invalidExtensionElement",
350 e.getTagName(),
351 e.getNamespaceURI());
352 return false; // keep compiler happy 238 return false; // keep compiler happy
353 } 239 }
240 }
241
242 private boolean handleHeaderElement(TWSDLExtensible parent, Element e, TWSDLParserContextImpl context) {
243 context.push();
244 context.registerNamespaces(e);
245
246 SOAPHeader header = new SOAPHeader(context.getLocation(e));
247
248 String use = XmlUtil.getAttributeOrNull(e, Constants.ATTR_USE);
249 if (use != null) {
250 if (use.equals(Constants.ATTRVALUE_LITERAL)) {
251 header.setUse(SOAPUse.LITERAL);
252 } else if (use.equals(Constants.ATTRVALUE_ENCODED)) {
253 header.setUse(SOAPUse.ENCODED);
254 } else {
255 Util.fail("parsing.invalidAttributeValue", Constants.ATTR_USE, use);
256 }
257 }
258
259 String namespace = XmlUtil.getAttributeOrNull(e, Constants.ATTR_NAMESPACE);
260 if (namespace != null) {
261 header.setNamespace(namespace);
262 }
263
264 String encodingStyle = XmlUtil.getAttributeOrNull(e, Constants.ATTR_ENCODING_STYLE);
265 if (encodingStyle != null) {
266 header.setEncodingStyle(encodingStyle);
267 }
268
269 String part = XmlUtil.getAttributeOrNull(e, Constants.ATTR_PART);
270 if (part != null) {
271 header.setPart(part);
272 }
273
274 String messageAttr = XmlUtil.getAttributeOrNull(e, Constants.ATTR_MESSAGE);
275 if (messageAttr != null) {
276 header.setMessage(context.translateQualifiedName(context.getLocation(e), messageAttr));
277 }
278
279 for (Iterator iter = XmlUtil.getAllChildren(e); iter.hasNext();) {
280 Element e2 = Util.nextElement(iter);
281 if (e2 == null)
282 break;
283
284 if (XmlUtil.matchesTagNS(e2, getHeaderfaultQName())) {
285 handleHeaderFaultElement(e, context, header, use, e2);
286 } else {
287 Util.fail("parsing.invalidElement", e2.getTagName(), e2.getNamespaceURI());
288 }
289 }
290
291 parent.addExtension(header);
292 context.pop();
293 context.fireDoneParsingEntity(getHeaderQName(), header);
294 return true;
295 }
296
297 private void handleHeaderFaultElement(Element e, TWSDLParserContextImpl context, SOAPHeader header, String use, Element e2) {
298 context.push();
299 context.registerNamespaces(e);
300
301 SOAPHeaderFault headerfault = new SOAPHeaderFault(context.getLocation(e));
302
303 String use2 = XmlUtil.getAttributeOrNull(e2, Constants.ATTR_USE);
304 if (use2 != null) {
305 if (use2.equals(Constants.ATTRVALUE_LITERAL)) {
306 headerfault.setUse(SOAPUse.LITERAL);
307 } else if (use.equals(Constants.ATTRVALUE_ENCODED)) {
308 headerfault.setUse(SOAPUse.ENCODED);
309 } else {
310 Util.fail("parsing.invalidAttributeValue", Constants.ATTR_USE, use2);
311 }
312 }
313
314 String namespace2 = XmlUtil.getAttributeOrNull(e2, Constants.ATTR_NAMESPACE);
315 if (namespace2 != null) {
316 headerfault.setNamespace(namespace2);
317 }
318
319 String encodingStyle2 = XmlUtil.getAttributeOrNull(e2, Constants.ATTR_ENCODING_STYLE);
320 if (encodingStyle2 != null) {
321 headerfault.setEncodingStyle(encodingStyle2);
322 }
323
324 String part2 = XmlUtil.getAttributeOrNull(e2, Constants.ATTR_PART);
325 if (part2 != null) {
326 headerfault.setPart(part2);
327 }
328
329 String messageAttr2 = XmlUtil.getAttributeOrNull(e2, Constants.ATTR_MESSAGE);
330 if (messageAttr2 != null) {
331 headerfault.setMessage(
332 context.translateQualifiedName(context.getLocation(e2), messageAttr2));
333 }
334
335 header.add(headerfault);
336 context.pop();
354 } 337 }
355 338
356 public boolean handleFaultExtension( 339 public boolean handleFaultExtension(
357 TWSDLParserContext context, 340 TWSDLParserContext context,
358 TWSDLExtensible parent, 341 TWSDLExtensible parent,
396 379
397 parent.addExtension(fault); 380 parent.addExtension(fault);
398 context.pop(); 381 context.pop();
399 // context.fireDoneParsingEntity(getFaultQName(), fault); 382 // context.fireDoneParsingEntity(getFaultQName(), fault);
400 return true; 383 return true;
384 } else if (XmlUtil.matchesTagNS(e, getHeaderQName())) {
385 // although SOAP spec doesn't define meaning of this extension; it is allowed
386 // to be here, so we have to accept it, not fail (bug 13576977)
387 return handleHeaderElement(parent, e, (TWSDLParserContextImpl) context);
401 } else { 388 } else {
402 Util.fail( 389 Util.fail(
403 "parsing.invalidExtensionElement", 390 "parsing.invalidExtensionElement",
404 e.getTagName(), 391 e.getTagName(),
405 e.getNamespaceURI()); 392 e.getNamespaceURI());

mercurial