Java Code Examples for javax.wsdl.Port#getExtensibilityElements()
The following examples show how to use
javax.wsdl.Port#getExtensibilityElements() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WSDLImporter.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
/** * Imports the service from the WSDL service definition */ protected WSService importService(Service service) { String name = service.getQName().getLocalPart(); Port port = (Port) service.getPorts().values().iterator().next(); String location = ""; List extensionElements = port.getExtensibilityElements(); for (Object extension : extensionElements) { if (extension instanceof SOAPAddress) { SOAPAddress address = (SOAPAddress) extension; location = address.getLocationURI(); } } WSService wsService = new WSService(this.namespace + name, location, this.wsdlLocation); return wsService; }
Example 2
Source File: WSDLImporter.java From flowable-engine with Apache License 2.0 | 6 votes |
/** * Imports the service from the WSDL service definition */ protected WSService importService(Service service) { String name = service.getQName().getLocalPart(); Port port = (Port) service.getPorts().values().iterator().next(); String location = ""; List extensionElements = port.getExtensibilityElements(); for (Object extension : extensionElements) { if (extension instanceof SOAPAddress) { SOAPAddress address = (SOAPAddress) extension; location = address.getLocationURI(); } } WSService wsService = new WSService(this.namespace + name, location, this.wsdlLocation); return wsService; }
Example 3
Source File: WSDL2UDDI.java From juddi with Apache License 2.0 | 6 votes |
/** * Obtains the accessUrl from the WSDL * * @param port * @return a string url * @throws MalformedURLException */ private String getBindingURL(Port port) throws MalformedURLException { String bindingUrl = null; for (Object element : port.getExtensibilityElements()) { if (element instanceof SOAPAddress) { SOAPAddress address = (SOAPAddress) element; URL locationURI = new URL(address.getLocationURI()); if (locationURI != null) { bindingUrl = urlLocalizer.rewrite(locationURI); break; } } } return bindingUrl; }
Example 4
Source File: ODEEndpointUpdater.java From container with Apache License 2.0 | 6 votes |
/** * Changes address in the given port if endpoint in the endpoint service is available * * @param port the Port to update * @return true if change was made, else false */ private boolean changePortAddressWithEndpointDB(final Port port) { boolean changed = false; LOG.debug("Trying to match address element with available endpoints for port {} ", port.getName()); for (final Object obj : port.getExtensibilityElements()) { // in the wsdl spec they use the extensibility mechanism final ExtensibilityElement element = (ExtensibilityElement) obj; for (final WSDLEndpoint endpoint : getWSDLEndpointsFromEndpointDB(port)) { LOG.debug("Changing address for endpoint: {}", endpoint.getURI()); if (changeAddress(element, endpoint)) { changed = true; } } } return changed; }
Example 5
Source File: WSDL11ProcessorImpl.java From carbon-apimgt with Apache License 2.0 | 6 votes |
/** * Get endpoints defined in the provided WSDL definition. * * @param definition WSDL Definition * @return a Map of endpoint names and their URIs. * @throws APIMgtWSDLException if error occurs while reading endpoints */ private Map<String, String> getEndpoints(Definition definition) throws APIMgtWSDLException { Map serviceMap = definition.getAllServices(); Iterator serviceItr = serviceMap.entrySet().iterator(); Map<String, String> serviceEndpointMap = new HashMap<>(); while (serviceItr.hasNext()) { Map.Entry svcEntry = (Map.Entry) serviceItr.next(); Service svc = (Service) svcEntry.getValue(); Map portMap = svc.getPorts(); for (Object o : portMap.entrySet()) { Map.Entry portEntry = (Map.Entry) o; Port port = (Port) portEntry.getValue(); List extensibilityElementList = port.getExtensibilityElements(); for (Object extensibilityElement : extensibilityElementList) { String addressURI = getAddressUrl(extensibilityElement); serviceEndpointMap.put(port.getName(), addressURI); } } } return serviceEndpointMap; }
Example 6
Source File: JAXBExtensionHelperTest.java From cxf with Apache License 2.0 | 6 votes |
private void checkTestExt() throws Exception { Service s = wsdlDefinition.getService(new QName("http://cxf.apache.org/test/hello_world", "HelloWorldService")); Port p = s.getPort("HelloWorldPort"); List<?> extPortList = p.getExtensibilityElements(); TestPolicyType tp = null; AnotherPolicyType ap = null; for (Object ext : extPortList) { if (ext instanceof TestPolicyType) { tp = (TestPolicyType) ext; } else if (ext instanceof AnotherPolicyType) { ap = (AnotherPolicyType) ext; } else if (ext instanceof UnknownExtensibilityElement) { UnknownExtensibilityElement e = (UnknownExtensibilityElement)ext; System.out.println(e.getElementType()); } } assertNotNull("Could not find extension element TestPolicyType", tp); assertNotNull("Could not find extension element AnotherPolicyType", ap); assertEquals("Unexpected value for TestPolicyType intAttr", 30, tp.getIntAttr()); assertEquals("Unexpected value for TestPolicyType stringAttr", "hello", tp.getStringAttr()); assertTrue("Unexpected value for AnotherPolicyType floatAttr", Math.abs(0.1F - ap.getFloatAttr()) < 0.5E-5); }
Example 7
Source File: ServiceRefFactory.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * @param port analyzed port * @return Returns the endpoint URL of the given Port */ private String getSOAPLocation(Port port) { String endpoint = null; @SuppressWarnings("unchecked") // Can't change the API List<ExtensibilityElement> extensions = port.getExtensibilityElements(); for (ExtensibilityElement ext : extensions) { if (ext instanceof SOAPAddress) { SOAPAddress addr = (SOAPAddress) ext; endpoint = addr.getLocationURI(); } } return endpoint; }
Example 8
Source File: ServiceRefFactory.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * @param port analyzed port * @return Returns the endpoint URL of the given Port */ private String getSOAPLocation(Port port) { String endpoint = null; @SuppressWarnings("unchecked") // Can't change the API List<ExtensibilityElement> extensions = port.getExtensibilityElements(); for (Iterator<ExtensibilityElement> i = extensions.iterator(); i.hasNext();) { ExtensibilityElement ext = i.next(); if (ext instanceof SOAPAddress) { SOAPAddress addr = (SOAPAddress) ext; endpoint = addr.getLocationURI(); } } return endpoint; }
Example 9
Source File: ServiceRefFactory.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * @param port analyzed port * @return Returns the endpoint URL of the given Port */ private String getSOAPLocation(Port port) { String endpoint = null; @SuppressWarnings("unchecked") // Can't change the API List<ExtensibilityElement> extensions = port.getExtensibilityElements(); for (Iterator<ExtensibilityElement> i = extensions.iterator(); i.hasNext();) { ExtensibilityElement ext = i.next(); if (ext instanceof SOAPAddress) { SOAPAddress addr = (SOAPAddress) ext; endpoint = addr.getLocationURI(); } } return endpoint; }
Example 10
Source File: WSDLUtils.java From tesb-studio-se with Apache License 2.0 | 5 votes |
public static String getPortAddress(final Port port) { final Collection<?> extensibilityElements = port.getExtensibilityElements(); SOAPAddress soapAddress = findExtensibilityElement(extensibilityElements, SOAPAddress.class); if (null != soapAddress) { return soapAddress.getLocationURI(); } SOAP12Address soap12Address = findExtensibilityElement(extensibilityElements, SOAP12Address.class); if (null != soap12Address) { return soap12Address.getLocationURI(); } return null; }
Example 11
Source File: ODEEndpointUpdater.java From container with Apache License 2.0 | 5 votes |
private boolean changePortAddressWithBpelEngineEndpoints(final Service service, final Port port) { boolean changed = false; for (final Object obj : port.getExtensibilityElements()) { final ExtensibilityElement element = (ExtensibilityElement) obj; for (final WSDLEndpoint endpoint : getWSDLEndpointForBpelEngineCallback(service, port)) { if (changeAddress(element, endpoint)) { changed = true; } } } return changed; }
Example 12
Source File: WSDLGetUtils.java From cxf with Apache License 2.0 | 5 votes |
protected void setSoapAddressLocationOn(Port port, String url) { List<?> extensions = port.getExtensibilityElements(); for (Object extension : extensions) { if (extension instanceof SOAP12Address) { ((SOAP12Address)extension).setLocationURI(url); } else if (extension instanceof SOAPAddress) { ((SOAPAddress)extension).setLocationURI(url); } } }
Example 13
Source File: WSPortConnector.java From development with Apache License 2.0 | 4 votes |
/** * Reads the WSDL and determines the target namespace. * * @param locator * The URL of the WSDL. * @param host * optional the host to be used when the one from the wsdl must * not be used * @return The service's target namespace. * @throws WSDLException * Thrown in case the WSDL could not be evaluated. */ private WSPortDescription getServiceDetails(WSDLLocator locator, String host) throws WSDLException { WSDLFactory wsdlFactory = WSDLFactory.newInstance(); WSDLReader wsdlReader = wsdlFactory.newWSDLReader(); Definition serviceDefinition = wsdlReader.readWSDL(locator); String tns = serviceDefinition.getTargetNamespace(); // read the port name String endpointURL = null; final Map<?, ?> services = serviceDefinition.getServices(); if (services != null) { for (Object serviceValue : services.values()) { javax.wsdl.Service service = (javax.wsdl.Service) serviceValue; Map<?, ?> ports = service.getPorts(); if (ports != null) { for (Object portValue : ports.values()) { Port port = (Port) portValue; List<?> extensibilityElements = port .getExtensibilityElements(); for (Object ex : extensibilityElements) { ExtensibilityElement ext = (ExtensibilityElement) ex; if (ext instanceof SOAPAddress) { SOAPAddress address = (SOAPAddress) ext; endpointURL = address.getLocationURI(); if (host != null) { int idx = endpointURL.indexOf("//") + 2; String tmp = endpointURL.substring(0, idx) + host + endpointURL.substring(endpointURL .indexOf(':', idx)); endpointURL = tmp; } } } } } } } WSPortDescription result = new WSPortDescription(); result.setTargetNamespace(tns); result.setEndpointURL(endpointURL); Element versionElement = serviceDefinition.getDocumentationElement(); if (versionElement != null) { result.setVersion(versionElement.getTextContent()); } return result; }
Example 14
Source File: PublishedEndpointUrlTest.java From cxf with Apache License 2.0 | 4 votes |
@Test public void testPublishedEndpointUrl() throws Exception { Greeter implementor = new org.apache.hello_world_soap_http.GreeterImpl(); String publishedEndpointUrl = "http://cxf.apache.org/publishedEndpointUrl"; Bus bus = BusFactory.getDefaultBus(); JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean(); svrFactory.setBus(bus); svrFactory.setServiceClass(Greeter.class); svrFactory.setAddress("http://localhost:" + PORT + "/publishedEndpointUrl"); svrFactory.setPublishedEndpointUrl(publishedEndpointUrl); svrFactory.setServiceBean(implementor); Server server = svrFactory.create(); WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); wsdlReader.setFeature("javax.wsdl.verbose", false); URL url = new URL(svrFactory.getAddress() + "?wsdl=1"); HttpURLConnection connect = (HttpURLConnection)url.openConnection(); assertEquals(500, connect.getResponseCode()); Definition wsdl = wsdlReader.readWSDL(svrFactory.getAddress() + "?wsdl"); assertNotNull(wsdl); Collection<Service> services = CastUtils.cast(wsdl.getAllServices().values()); final String failMesg = "WSDL provided incorrect soap:address location"; for (Service service : services) { Collection<Port> ports = CastUtils.cast(service.getPorts().values()); for (Port port : ports) { List<?> extensions = port.getExtensibilityElements(); for (Object extension : extensions) { String actualUrl = null; if (extension instanceof SOAP12Address) { actualUrl = ((SOAP12Address)extension).getLocationURI(); } else if (extension instanceof SOAPAddress) { actualUrl = ((SOAPAddress)extension).getLocationURI(); } //System.out.println("Checking url: " + actualUrl + " against " + publishedEndpointUrl); assertEquals(failMesg, publishedEndpointUrl, actualUrl); } } } server.stop(); server.destroy(); bus.shutdown(true); }