src/share/jaxws_classes/com/sun/xml/internal/ws/wsdl/parser/RuntimeWSDLParser.java

changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 408
b0610cd08440
     1.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/ws/wsdl/parser/RuntimeWSDLParser.java	Thu Apr 04 19:05:24 2013 -0700
     1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/wsdl/parser/RuntimeWSDLParser.java	Tue Apr 09 14:51:13 2013 +0100
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -32,6 +32,7 @@
    1.11  import com.sun.xml.internal.stream.buffer.XMLStreamBufferMark;
    1.12  import com.sun.xml.internal.stream.buffer.stax.StreamReaderBufferCreator;
    1.13  import com.sun.xml.internal.ws.api.BindingID;
    1.14 +import com.sun.xml.internal.ws.api.BindingIDFactory;
    1.15  import com.sun.xml.internal.ws.api.SOAPVersion;
    1.16  import com.sun.xml.internal.ws.api.EndpointAddress;
    1.17  import com.sun.xml.internal.ws.api.WSDLLocator;
    1.18 @@ -100,6 +101,7 @@
    1.19      private final XMLEntityResolver resolver;
    1.20  
    1.21      private final PolicyResolver policyResolver;
    1.22 +
    1.23      /**
    1.24       * The {@link WSDLParserExtension}. Always non-null.
    1.25       */
    1.26 @@ -224,10 +226,6 @@
    1.27          return wsdlParser.wsdlDoc;
    1.28      }
    1.29  
    1.30 -    private static WSDLModelImpl tryWithMex(@NotNull RuntimeWSDLParser wsdlParser, @NotNull URL wsdlLoc, @NotNull EntityResolver resolver, boolean isClientSide, Container container, Throwable e, PolicyResolver policyResolver, WSDLParserExtension... extensions) throws SAXException, XMLStreamException {
    1.31 -        return tryWithMex(wsdlParser, wsdlLoc, resolver, isClientSide, container, e, Service.class, policyResolver, extensions);
    1.32 -    }
    1.33 -
    1.34      private static WSDLModelImpl tryWithMex(@NotNull RuntimeWSDLParser wsdlParser, @NotNull URL wsdlLoc, @NotNull EntityResolver resolver, boolean isClientSide, Container container, Throwable e, Class serviceClass, PolicyResolver policyResolver, WSDLParserExtension... extensions) throws SAXException, XMLStreamException {
    1.35          ArrayList<Throwable> exceptions = new ArrayList<Throwable>();
    1.36          try {
    1.37 @@ -246,10 +244,6 @@
    1.38          throw new InaccessibleWSDLException(exceptions);
    1.39      }
    1.40  
    1.41 -    private WSDLModelImpl parseUsingMex(@NotNull URL wsdlLoc, @NotNull EntityResolver resolver, boolean isClientSide, Container container, PolicyResolver policyResolver, WSDLParserExtension[] extensions) throws IOException, SAXException, XMLStreamException, URISyntaxException {
    1.42 -        return parseUsingMex(wsdlLoc, resolver, isClientSide, container, Service.class, policyResolver, extensions);
    1.43 -    }
    1.44 -
    1.45      private WSDLModelImpl parseUsingMex(@NotNull URL wsdlLoc, @NotNull EntityResolver resolver, boolean isClientSide, Container container, Class serviceClass, PolicyResolver policyResolver, WSDLParserExtension[] extensions) throws IOException, SAXException, XMLStreamException, URISyntaxException {
    1.46          //try MEX
    1.47          MetaDataResolver mdResolver = null;
    1.48 @@ -347,10 +341,6 @@
    1.49          this.extensionFacade =  new WSDLParserExtensionFacade(this.extensions.toArray(new WSDLParserExtension[0]));
    1.50      }
    1.51  
    1.52 -    private Parser resolveWSDL(@Nullable URL wsdlLoc, @NotNull Source wsdlSource) throws IOException, SAXException, XMLStreamException {
    1.53 -        return resolveWSDL(wsdlLoc, wsdlSource, Service.class);
    1.54 -    }
    1.55 -
    1.56      private Parser resolveWSDL(@Nullable URL wsdlLoc, @NotNull Source wsdlSource, Class serviceClass) throws IOException, SAXException, XMLStreamException {
    1.57          String systemId = wsdlSource.getSystemId();
    1.58  
    1.59 @@ -369,22 +359,22 @@
    1.60                  }
    1.61              }
    1.62          }
    1.63 -        if(parser == null){
    1.64 -                //If a WSDL source is provided that is known to be readable, then
    1.65 -                //prioritize that over the URL - this avoids going over the network
    1.66 -                //an additional time if a valid WSDL Source is provided - Deva Sagar 09/20/2011
    1.67 -                if (wsdlSource != null && isKnownReadableSource(wsdlSource)) {
    1.68 +        if (parser == null) {
    1.69 +            //If a WSDL source is provided that is known to be readable, then
    1.70 +            //prioritize that over the URL - this avoids going over the network
    1.71 +            //an additional time if a valid WSDL Source is provided - Deva Sagar 09/20/2011
    1.72 +            if (isKnownReadableSource(wsdlSource)) {
    1.73                  parser = new Parser(wsdlLoc, createReader(wsdlSource));
    1.74 -                } else if (wsdlLoc != null) {
    1.75 -                        parser = new Parser(wsdlLoc, createReader(wsdlLoc, serviceClass));
    1.76 -                }
    1.77 +            } else if (wsdlLoc != null) {
    1.78 +                parser = new Parser(wsdlLoc, createReader(wsdlLoc, serviceClass));
    1.79 +            }
    1.80  
    1.81 -                //parser could still be null if isKnownReadableSource returns
    1.82 -                //false and wsdlLoc is also null. Fall back to using Source based
    1.83 -                //parser since Source is not null
    1.84 -                if (parser == null) {
    1.85 -                        parser = new Parser(wsdlLoc, createReader(wsdlSource));
    1.86 -                }
    1.87 +            //parser could still be null if isKnownReadableSource returns
    1.88 +            //false and wsdlLoc is also null. Fall back to using Source based
    1.89 +            //parser since Source is not null
    1.90 +            if (parser == null) {
    1.91 +                parser = new Parser(wsdlLoc, createReader(wsdlSource));
    1.92 +            }
    1.93          }
    1.94          return parser;
    1.95      }
    1.96 @@ -568,7 +558,9 @@
    1.97          while (XMLStreamReaderUtil.nextElementContent(reader) != XMLStreamConstants.END_ELEMENT) {
    1.98              QName name = reader.getName();
    1.99              if (WSDLConstants.NS_SOAP_BINDING.equals(name)) {
   1.100 -                binding.setBindingId(BindingID.SOAP11_HTTP);
   1.101 +                String transport = reader.getAttributeValue(null, WSDLConstants.ATTR_TRANSPORT);
   1.102 +                binding.setBindingId(createBindingId(transport, SOAPVersion.SOAP_11));
   1.103 +
   1.104                  String style = reader.getAttributeValue(null, "style");
   1.105  
   1.106                  if ((style != null) && (style.equals("rpc"))) {
   1.107 @@ -578,7 +570,9 @@
   1.108                  }
   1.109                  goToEnd(reader);
   1.110              } else if (WSDLConstants.NS_SOAP12_BINDING.equals(name)) {
   1.111 -                binding.setBindingId(BindingID.SOAP12_HTTP);
   1.112 +                String transport = reader.getAttributeValue(null, WSDLConstants.ATTR_TRANSPORT);
   1.113 +                binding.setBindingId(createBindingId(transport, SOAPVersion.SOAP_12));
   1.114 +
   1.115                  String style = reader.getAttributeValue(null, "style");
   1.116                  if ((style != null) && (style.equals("rpc"))) {
   1.117                      binding.setStyle(Style.RPC);
   1.118 @@ -594,6 +588,18 @@
   1.119          }
   1.120      }
   1.121  
   1.122 +    private static BindingID createBindingId(String transport, SOAPVersion soapVersion) {
   1.123 +        if (!transport.equals(SOAPConstants.URI_SOAP_TRANSPORT_HTTP)) {
   1.124 +            for( BindingIDFactory f : ServiceFinder.find(BindingIDFactory.class) ) {
   1.125 +                BindingID bindingId = f.create(transport, soapVersion);
   1.126 +                if(bindingId!=null) {
   1.127 +                    return bindingId;
   1.128 +                }
   1.129 +            }
   1.130 +        }
   1.131 +        return soapVersion.equals(SOAPVersion.SOAP_11)?BindingID.SOAP11_HTTP:BindingID.SOAP12_HTTP;
   1.132 +    }
   1.133 +
   1.134  
   1.135      private void parseBindingOperation(XMLStreamReader reader, WSDLBoundPortTypeImpl binding) {
   1.136          String bindingOpName = ParserUtil.getMandatoryNonEmptyAttribute(reader, "name");
   1.137 @@ -913,7 +919,7 @@
   1.138                      QName descName = reader.getAttributeName(i);
   1.139                      if (descName.getLocalPart().equals("element"))
   1.140                          kind = WSDLDescriptorKind.ELEMENT;
   1.141 -                    else if (descName.getLocalPart().equals("TYPE"))
   1.142 +                    else if (descName.getLocalPart().equals("type"))
   1.143                          kind = WSDLDescriptorKind.TYPE;
   1.144  
   1.145                      if (descName.getLocalPart().equals("element") || descName.getLocalPart().equals("type")) {

mercurial