@Test public void parseSoapAPI() { final SoapApiModelInfo soapApiModelInfo = SoapApiModelParser.parseSoapAPI(this.specification, this.specification); assertThat(soapApiModelInfo).isNotNull(); assertThat(soapApiModelInfo.getErrors()).isEmpty(); assertThat(soapApiModelInfo.getWarnings()).isEmpty(); assertThat(soapApiModelInfo.getResolvedSpecification()).isNotNull(); assertThat(soapApiModelInfo.getModel()).isNotNull(); assertThat(soapApiModelInfo.getServices()).isNotNull(); assertThat(soapApiModelInfo.getPorts()).isNotNull(); assertThat(soapApiModelInfo.getDefaultService()).isNotNull(); assertThat(soapApiModelInfo.getDefaultPort()).isNotNull(); assertThat(soapApiModelInfo.getDefaultAddress()).isNotNull(); }
public static SoapApiModelInfo parseSoapAPI(final String specification, final String wsdlURL) { SoapApiModelInfo.Builder builder = new SoapApiModelInfo.Builder(); try { final String resolvedSpecification; final Optional<String> resolvedWsdlURL; final boolean isHttpUrl = specification.toLowerCase(Locale.US).startsWith("http"); if (isHttpUrl) { final URL httpURL = new URL(specification); resolvedWsdlURL = Optional.of(httpURL.toString()); final HttpURLConnection connection = (HttpURLConnection) httpURL.openConnection(); connection.setRequestMethod("GET"); if (connection.getResponseCode() > 299) { throw new IOException(connection.getResponseMessage()); } resolvedSpecification = IOStreams.readText(connection.getInputStream()); } else { resolvedSpecification = specification; resolvedWsdlURL = Optional.ofNullable(wsdlURL); } builder.wsdlURL(resolvedWsdlURL); final String condensedSpecification = condenseWSDL(resolvedSpecification); builder.resolvedSpecification(condensedSpecification); final InputSource inputSource = new InputSource(new StringReader(condensedSpecification)); final Definition definition = getWsdlReader().readWSDL(resolvedWsdlURL.orElse(null), inputSource); builder.model(definition); validateModel(definition, builder); final SoapApiModelInfo localBuild = builder.build(); if (localBuild.getServices().size() == 1) { final QName defaultService = localBuild.getServices().get(0); builder.defaultService(defaultService); final List<String> ports = localBuild.getPorts().get(defaultService); if (ports.size() == 1) { final String defaultPort = ports.get(0); builder.defaultPort(defaultPort); String locationURI = getAddress(definition, defaultService, defaultPort); if (locationURI != null) { builder.defaultAddress(locationURI); } } } } catch (IOException e) { addError(builder, "Error reading WSDL: " + e.getMessage(), e); } catch (WSDLException | BusException e) { addError(builder, "Error parsing WSDL: " + e.getMessage(), e); } catch (TransformerException e) { addError(builder, "Error condensing WSDL: " + e.getMessage(), e); } return builder.build(); }
SoapApiModelParser { public static SoapApiModelInfo parseSoapAPI(final String specification, final String wsdlURL) { SoapApiModelInfo.Builder builder = new SoapApiModelInfo.Builder(); try { final String resolvedSpecification; final Optional<String> resolvedWsdlURL; final boolean isHttpUrl = specification.toLowerCase(Locale.US).startsWith("http"); if (isHttpUrl) { final URL httpURL = new URL(specification); resolvedWsdlURL = Optional.of(httpURL.toString()); final HttpURLConnection connection = (HttpURLConnection) httpURL.openConnection(); connection.setRequestMethod("GET"); if (connection.getResponseCode() > 299) { throw new IOException(connection.getResponseMessage()); } resolvedSpecification = IOStreams.readText(connection.getInputStream()); } else { resolvedSpecification = specification; resolvedWsdlURL = Optional.ofNullable(wsdlURL); } builder.wsdlURL(resolvedWsdlURL); final String condensedSpecification = condenseWSDL(resolvedSpecification); builder.resolvedSpecification(condensedSpecification); final InputSource inputSource = new InputSource(new StringReader(condensedSpecification)); final Definition definition = getWsdlReader().readWSDL(resolvedWsdlURL.orElse(null), inputSource); builder.model(definition); validateModel(definition, builder); final SoapApiModelInfo localBuild = builder.build(); if (localBuild.getServices().size() == 1) { final QName defaultService = localBuild.getServices().get(0); builder.defaultService(defaultService); final List<String> ports = localBuild.getPorts().get(defaultService); if (ports.size() == 1) { final String defaultPort = ports.get(0); builder.defaultPort(defaultPort); String locationURI = getAddress(definition, defaultService, defaultPort); if (locationURI != null) { builder.defaultAddress(locationURI); } } } } catch (IOException e) { addError(builder, "Error reading WSDL: " + e.getMessage(), e); } catch (WSDLException | BusException e) { addError(builder, "Error parsing WSDL: " + e.getMessage(), e); } catch (TransformerException e) { addError(builder, "Error condensing WSDL: " + e.getMessage(), e); } return builder.build(); } }
SoapApiModelParser { public static SoapApiModelInfo parseSoapAPI(final String specification, final String wsdlURL) { SoapApiModelInfo.Builder builder = new SoapApiModelInfo.Builder(); try { final String resolvedSpecification; final Optional<String> resolvedWsdlURL; final boolean isHttpUrl = specification.toLowerCase(Locale.US).startsWith("http"); if (isHttpUrl) { final URL httpURL = new URL(specification); resolvedWsdlURL = Optional.of(httpURL.toString()); final HttpURLConnection connection = (HttpURLConnection) httpURL.openConnection(); connection.setRequestMethod("GET"); if (connection.getResponseCode() > 299) { throw new IOException(connection.getResponseMessage()); } resolvedSpecification = IOStreams.readText(connection.getInputStream()); } else { resolvedSpecification = specification; resolvedWsdlURL = Optional.ofNullable(wsdlURL); } builder.wsdlURL(resolvedWsdlURL); final String condensedSpecification = condenseWSDL(resolvedSpecification); builder.resolvedSpecification(condensedSpecification); final InputSource inputSource = new InputSource(new StringReader(condensedSpecification)); final Definition definition = getWsdlReader().readWSDL(resolvedWsdlURL.orElse(null), inputSource); builder.model(definition); validateModel(definition, builder); final SoapApiModelInfo localBuild = builder.build(); if (localBuild.getServices().size() == 1) { final QName defaultService = localBuild.getServices().get(0); builder.defaultService(defaultService); final List<String> ports = localBuild.getPorts().get(defaultService); if (ports.size() == 1) { final String defaultPort = ports.get(0); builder.defaultPort(defaultPort); String locationURI = getAddress(definition, defaultService, defaultPort); if (locationURI != null) { builder.defaultAddress(locationURI); } } } } catch (IOException e) { addError(builder, "Error reading WSDL: " + e.getMessage(), e); } catch (WSDLException | BusException e) { addError(builder, "Error parsing WSDL: " + e.getMessage(), e); } catch (TransformerException e) { addError(builder, "Error condensing WSDL: " + e.getMessage(), e); } return builder.build(); } private  SoapApiModelParser(); }
SoapApiModelParser { public static SoapApiModelInfo parseSoapAPI(final String specification, final String wsdlURL) { SoapApiModelInfo.Builder builder = new SoapApiModelInfo.Builder(); try { final String resolvedSpecification; final Optional<String> resolvedWsdlURL; final boolean isHttpUrl = specification.toLowerCase(Locale.US).startsWith("http"); if (isHttpUrl) { final URL httpURL = new URL(specification); resolvedWsdlURL = Optional.of(httpURL.toString()); final HttpURLConnection connection = (HttpURLConnection) httpURL.openConnection(); connection.setRequestMethod("GET"); if (connection.getResponseCode() > 299) { throw new IOException(connection.getResponseMessage()); } resolvedSpecification = IOStreams.readText(connection.getInputStream()); } else { resolvedSpecification = specification; resolvedWsdlURL = Optional.ofNullable(wsdlURL); } builder.wsdlURL(resolvedWsdlURL); final String condensedSpecification = condenseWSDL(resolvedSpecification); builder.resolvedSpecification(condensedSpecification); final InputSource inputSource = new InputSource(new StringReader(condensedSpecification)); final Definition definition = getWsdlReader().readWSDL(resolvedWsdlURL.orElse(null), inputSource); builder.model(definition); validateModel(definition, builder); final SoapApiModelInfo localBuild = builder.build(); if (localBuild.getServices().size() == 1) { final QName defaultService = localBuild.getServices().get(0); builder.defaultService(defaultService); final List<String> ports = localBuild.getPorts().get(defaultService); if (ports.size() == 1) { final String defaultPort = ports.get(0); builder.defaultPort(defaultPort); String locationURI = getAddress(definition, defaultService, defaultPort); if (locationURI != null) { builder.defaultAddress(locationURI); } } } } catch (IOException e) { addError(builder, "Error reading WSDL: " + e.getMessage(), e); } catch (WSDLException | BusException e) { addError(builder, "Error parsing WSDL: " + e.getMessage(), e); } catch (TransformerException e) { addError(builder, "Error condensing WSDL: " + e.getMessage(), e); } return builder.build(); } private  SoapApiModelParser(); static SoapApiModelInfo parseSoapAPI(final String specification, final String wsdlURL); static String getAddress(Definition definition, QName service, String port); static ActionsSummary parseActionsSummary(Definition definition, QName serviceName, String portName); static List<ConnectorAction> parseActions(Definition definition, QName serviceName, QName portName,
                                                     String connectorId); }
SoapApiModelParser { public static SoapApiModelInfo parseSoapAPI(final String specification, final String wsdlURL) { SoapApiModelInfo.Builder builder = new SoapApiModelInfo.Builder(); try { final String resolvedSpecification; final Optional<String> resolvedWsdlURL; final boolean isHttpUrl = specification.toLowerCase(Locale.US).startsWith("http"); if (isHttpUrl) { final URL httpURL = new URL(specification); resolvedWsdlURL = Optional.of(httpURL.toString()); final HttpURLConnection connection = (HttpURLConnection) httpURL.openConnection(); connection.setRequestMethod("GET"); if (connection.getResponseCode() > 299) { throw new IOException(connection.getResponseMessage()); } resolvedSpecification = IOStreams.readText(connection.getInputStream()); } else { resolvedSpecification = specification; resolvedWsdlURL = Optional.ofNullable(wsdlURL); } builder.wsdlURL(resolvedWsdlURL); final String condensedSpecification = condenseWSDL(resolvedSpecification); builder.resolvedSpecification(condensedSpecification); final InputSource inputSource = new InputSource(new StringReader(condensedSpecification)); final Definition definition = getWsdlReader().readWSDL(resolvedWsdlURL.orElse(null), inputSource); builder.model(definition); validateModel(definition, builder); final SoapApiModelInfo localBuild = builder.build(); if (localBuild.getServices().size() == 1) { final QName defaultService = localBuild.getServices().get(0); builder.defaultService(defaultService); final List<String> ports = localBuild.getPorts().get(defaultService); if (ports.size() == 1) { final String defaultPort = ports.get(0); builder.defaultPort(defaultPort); String locationURI = getAddress(definition, defaultService, defaultPort); if (locationURI != null) { builder.defaultAddress(locationURI); } } } } catch (IOException e) { addError(builder, "Error reading WSDL: " + e.getMessage(), e); } catch (WSDLException | BusException e) { addError(builder, "Error parsing WSDL: " + e.getMessage(), e); } catch (TransformerException e) { addError(builder, "Error condensing WSDL: " + e.getMessage(), e); } return builder.build(); } private  SoapApiModelParser(); static SoapApiModelInfo parseSoapAPI(final String specification, final String wsdlURL); static String getAddress(Definition definition, QName service, String port); static ActionsSummary parseActionsSummary(Definition definition, QName serviceName, String portName); static List<ConnectorAction> parseActions(Definition definition, QName serviceName, QName portName,
                                                     String connectorId);  }