Java Code Examples for javax.wsdl.Service#getPorts()
The following examples show how to use
javax.wsdl.Service#getPorts() .
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: WSDL2UDDI.java From juddi with Apache License 2.0 | 6 votes |
public BusinessServices registerBusinessServices(Definition wsdlDefinition) throws RemoteException, ConfigurationException, TransportException, WSDLException, MalformedURLException { BusinessServices businessServices = new BusinessServices(); for (Object serviceName : wsdlDefinition.getAllServices().keySet()) { QName serviceQName = (QName) serviceName; Service service = wsdlDefinition.getService(serviceQName); BusinessService businessService = null; //add service URL serviceUrl = null; if (service.getPorts() != null && service.getPorts().size() > 0) { for (Object portName : service.getPorts().keySet()) { businessService = registerBusinessService(serviceQName, (String) portName, serviceUrl, wsdlDefinition).getBusinessService(); } } if (businessService != null) { businessServices.getBusinessService().add(businessService); } } return businessServices; }
Example 2
Source File: WSDL2UDDI.java From juddi with Apache License 2.0 | 6 votes |
/** * Creates a business service based off of a WSDL definition<Br>No * changes are made to the UDDI endpoints using this method * <br> * Example Code: * <pre> * URL url = new URL("http://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php?wsdl"); * String domain = url.getHost(); * ReadWSDL rw = new ReadWSDL(); * Definition wsdlDefinition = rw.readWSDL(url); * properties.put("keyDomain", domain); * properties.put("businessName", domain); * properties.put("serverName", url.getHost()); * properties.put("serverPort", url.getPort()); * wsdlURL = wsdlDefinition.getDocumentBaseURI(); * WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(null, new URLLocalizerDefaultImpl(), properties); * BusinessServices businessServices = wsdl2UDDI.createBusinessServices(wsdlDefinition); * </pre> * * @param wsdlDefinition must not be null * @return a business service * @throws MalformedURLException * @throws IllegalArgumentException if the wsdlDefinition is null */ public BusinessServices createBusinessServices(Definition wsdlDefinition) throws MalformedURLException { if (wsdlDefinition == null) { throw new IllegalArgumentException(); } BusinessServices businessServices = new BusinessServices(); for (Object serviceName : wsdlDefinition.getAllServices().keySet()) { QName serviceQName = (QName) serviceName; Service service = wsdlDefinition.getService(serviceQName); BusinessService businessService = createBusinessService(serviceQName, wsdlDefinition); //service.getExtensibilityElements(). //add the bindingTemplates URL serviceUrl = null; if (service.getPorts() != null && service.getPorts().size() > 0) { businessService.setBindingTemplates(new BindingTemplates()); for (Object portName : service.getPorts().keySet()) { BindingTemplate bindingTemplate = createWSDLBinding(serviceQName, (String) portName, serviceUrl, wsdlDefinition); businessService.getBindingTemplates().getBindingTemplate().add(bindingTemplate); } } businessServices.getBusinessService().add(businessService); } return businessServices; }
Example 3
Source File: ManagementBusInvocationPluginSoapHttp.java From container with Apache License 2.0 | 6 votes |
private String getPortName(Definition wsdl, BindingOperation operation) { Binding binding = null; final Map<QName, ?> bindings = wsdl.getBindings(); for (Map.Entry<QName, ?> entry : bindings.entrySet()) { Binding examined = wsdl.getBinding((QName) entry.getKey()); if (examined.getBindingOperations().contains(operation)) { binding = examined; break; } } Map<QName, Service> services = wsdl.getServices(); for (Service service : services.values()) { Map<QName, Port> ports = service.getPorts(); for (Port port : ports.values()) { if (port.getBinding().equals(binding)) { return port.getName(); } } } return ""; }
Example 4
Source File: BPELPlanContext.java From container with Apache License 2.0 | 6 votes |
/** * Returns a List of Port which implement the given portType inside the given WSDL File * * @param portType the portType to use * @param wsdlFile the WSDL File to look in * @return a List of Port which implement the given PortType * @throws WSDLException is thrown when the given File is not a WSDL File or initializing the WSDL Factory failed */ public List<Port> getPortsInWSDLFileForPortType(final QName portType, final File wsdlFile) throws WSDLException { final List<Port> wsdlPorts = new ArrayList<>(); // taken from http://www.java.happycodings.com/Other/code24.html final WSDLFactory factory = WSDLFactory.newInstance(); final WSDLReader reader = factory.newWSDLReader(); reader.setFeature("javax.wsdl.verbose", false); final Definition wsdlInstance = reader.readWSDL(wsdlFile.getAbsolutePath()); final Map services = wsdlInstance.getAllServices(); for (final Object key : services.keySet()) { final Service service = (Service) services.get(key); final Map ports = service.getPorts(); for (final Object portKey : ports.keySet()) { final Port port = (Port) ports.get(portKey); if (port.getBinding().getPortType().getQName().getNamespaceURI().equals(portType.getNamespaceURI()) && port.getBinding().getPortType().getQName().getLocalPart().equals(portType.getLocalPart())) { wsdlPorts.add(port); } } } return wsdlPorts; }
Example 5
Source File: BPELPlanContext.java From container with Apache License 2.0 | 6 votes |
/** * Returns the Services inside the given WSDL file which implement the given portType * * @param portType the portType to search with * @param wsdlFile the WSDL file to look in * @return a List of Service which implement the given portType * @throws WSDLException is thrown when the WSDLFactory to read the WSDL can't be initialized */ private List<Service> getServicesInWSDLFile(final Path wsdlFile, final QName portType) throws WSDLException { final List<Service> servicesInWsdl = new ArrayList<>(); final WSDLFactory factory = WSDLFactory.newInstance(); final WSDLReader reader = factory.newWSDLReader(); reader.setFeature("javax.wsdl.verbose", false); final Definition wsdlInstance = reader.readWSDL(wsdlFile.toAbsolutePath().toString()); final Map services = wsdlInstance.getAllServices(); for (final Object key : services.keySet()) { final Service service = (Service) services.get(key); final Map ports = service.getPorts(); for (final Object portKey : ports.keySet()) { final Port port = (Port) ports.get(portKey); if (port.getBinding().getPortType().getQName().getNamespaceURI().equals(portType.getNamespaceURI()) && port.getBinding().getPortType().getQName().getLocalPart().equals(portType.getLocalPart())) { servicesInWsdl.add(service); } } } return servicesInWsdl; }
Example 6
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 7
Source File: WSDLDefinitionBuilderTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testBuildSimpleWSDL() throws Exception { String qname = "http://apache.org/hello_world_soap_http"; String wsdlUrl = getClass().getResource("hello_world.wsdl").toString(); WSDLDefinitionBuilder builder = new WSDLDefinitionBuilder(BusFactory.getDefaultBus()); Definition def = builder.build(wsdlUrl); assertNotNull(def); Map<?, ?> services = def.getServices(); assertNotNull(services); assertEquals(1, services.size()); Service service = (Service)services.get(new QName(qname, "SOAPService")); assertNotNull(service); Map<?, ?> ports = service.getPorts(); assertNotNull(ports); assertEquals(1, ports.size()); Port port = service.getPort("SoapPort"); assertNotNull(port); }
Example 8
Source File: WSDLDefinitionBuilderTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testBuildImportedWSDLSpacesInPath() throws Exception { WSDLDefinitionBuilder builder = new WSDLDefinitionBuilder(BusFactory.getDefaultBus()); String wsdlUrl = getClass().getResource("/folder with spaces/import_test.wsdl").toString(); Definition def = builder.build(wsdlUrl); assertNotNull(def); Map<?, ?> services = def.getServices(); assertNotNull(services); assertEquals(1, services.size()); String serviceQName = "urn:S1importS2S3/resources/wsdl/S1importsS2S3Test1"; Service service = (Service)services.get(new QName(serviceQName, "S1importsS2S3TestService")); assertNotNull(service); Map<?, ?> ports = service.getPorts(); assertNotNull(ports); assertEquals(1, ports.size()); Port port = service.getPort("S1importsS2S3TestPort"); assertNotNull(port); }
Example 9
Source File: WSDLManagerImplTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testBuildSimpleWSDL() throws Exception { String qname = "http://apache.org/hello_world_soap_http"; String wsdlUrl = getClass().getResource("hello_world.wsdl").toString(); WSDLManager builder = new WSDLManagerImpl(); Definition def = builder.getDefinition(wsdlUrl); assertNotNull(def); Map<?, ?> services = def.getServices(); assertNotNull(services); assertEquals(1, services.size()); Service service = (Service)services.get(new QName(qname, "SOAPService")); assertNotNull(service); Map<?, ?> ports = service.getPorts(); assertNotNull(ports); assertEquals(1, ports.size()); Port port = service.getPort("SoapPort"); assertNotNull(port); }
Example 10
Source File: BPELPlanContext.java From container with Apache License 2.0 | 5 votes |
/** * Returns the WSDL Ports of the given WSDL Service * * @param service the WSDL Service * @return a List of Port which belong to the service */ private List<Port> getPortsFromService(final Service service) { final List<Port> portOfService = new ArrayList<>(); final Map ports = service.getPorts(); for (final Object key : ports.keySet()) { portOfService.add((Port) ports.get(key)); } return portOfService; }
Example 11
Source File: WSDLDefinitionBuilderTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testBuildImportedWSDL() throws Exception { String wsdlUrl = getClass().getResource("hello_world_services.wsdl").toString(); WSDLDefinitionBuilder builder = new WSDLDefinitionBuilder(BusFactory.getDefaultBus()); Definition def = builder.build(wsdlUrl); assertNotNull(def); Map<?, ?> services = def.getServices(); assertNotNull(services); assertEquals(1, services.size()); String serviceQName = "http://apache.org/hello_world/services"; Service service = (Service)services.get(new QName(serviceQName, "SOAPService")); assertNotNull(service); Map<?, ?> ports = service.getPorts(); assertNotNull(ports); assertEquals(1, ports.size()); Port port = service.getPort("SoapPort"); assertNotNull(port); Binding binding = port.getBinding(); assertNotNull(binding); QName bindingQName = new QName("http://apache.org/hello_world/bindings", "SOAPBinding"); assertEquals(bindingQName, binding.getQName()); PortType portType = binding.getPortType(); assertNotNull(portType); QName portTypeQName = new QName("http://apache.org/hello_world", "Greeter"); assertEquals(portTypeQName, portType.getQName()); Operation op1 = portType.getOperation("sayHi", "sayHiRequest", "sayHiResponse"); assertNotNull(op1); QName messageQName = new QName("http://apache.org/hello_world/messages", "sayHiRequest"); assertEquals(messageQName, op1.getInput().getMessage().getQName()); Part part = op1.getInput().getMessage().getPart("in"); assertNotNull(part); assertEquals(new QName("http://apache.org/hello_world/types", "sayHi"), part.getElementName()); }
Example 12
Source File: WSDLManagerImplTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testBuildImportedWSDL() throws Exception { String wsdlUrl = getClass().getResource("hello_world_services.wsdl").toString(); WSDLManager builder = new WSDLManagerImpl(); Definition def = builder.getDefinition(wsdlUrl); assertNotNull(def); Map<?, ?> services = def.getServices(); assertNotNull(services); assertEquals(1, services.size()); String serviceQName = "http://apache.org/hello_world/services"; Service service = (Service)services.get(new QName(serviceQName, "SOAPService")); assertNotNull(service); Map<?, ?> ports = service.getPorts(); assertNotNull(ports); assertEquals(1, ports.size()); Port port = service.getPort("SoapPort"); assertNotNull(port); Binding binding = port.getBinding(); assertNotNull(binding); QName bindingQName = new QName("http://apache.org/hello_world/bindings", "SOAPBinding"); assertEquals(bindingQName, binding.getQName()); PortType portType = binding.getPortType(); assertNotNull(portType); QName portTypeQName = new QName("http://apache.org/hello_world", "Greeter"); assertEquals(portTypeQName, portType.getQName()); Operation op1 = portType.getOperation("sayHi", "sayHiRequest", "sayHiResponse"); assertNotNull(op1); QName messageQName = new QName("http://apache.org/hello_world/messages", "sayHiRequest"); assertEquals(messageQName, op1.getInput().getMessage().getQName()); Part part = op1.getInput().getMessage().getPart("in"); assertNotNull(part); assertEquals(new QName("http://apache.org/hello_world/types", "sayHi"), part.getElementName()); }
Example 13
Source File: EmbeddedJMSBrokerLauncher.java From cxf with Apache License 2.0 | 5 votes |
public static void updateWsdlExtensors(Bus bus, String wsdlLocation, String url, String encodedUrl) { try { if (encodedUrl == null) { encodedUrl = url; } if (bus == null) { bus = BusFactory.getThreadDefaultBus(); } Definition def = bus.getExtension(WSDLManager.class) .getDefinition(wsdlLocation); Map<?, ?> map = def.getAllServices(); for (Object o : map.values()) { Service service = (Service)o; Map<?, ?> ports = service.getPorts(); adjustExtensibilityElements(service.getExtensibilityElements(), url, encodedUrl); for (Object p : ports.values()) { Port port = (Port)p; adjustExtensibilityElements(port.getExtensibilityElements(), url, encodedUrl); adjustExtensibilityElements(port.getBinding().getExtensibilityElements(), url, encodedUrl); } } } catch (Exception e) { e.printStackTrace(); } }
Example 14
Source File: JAXWSDefinitionBuilderTest.java From cxf with Apache License 2.0 | 4 votes |
@Test public void testBuildDefinitionWithXMLBinding() { String qname = "http://apache.org/hello_world_xml_http/bare"; String wsdlUrl = getClass().getResource("resources/hello_world_xml_bare.wsdl").toString(); JAXWSDefinitionBuilder builder = new JAXWSDefinitionBuilder(); builder.setBus(BusFactory.getDefaultBus()); builder.setContext(env); Definition def = builder.build(wsdlUrl); assertNotNull(def); Map<?, ?> services = def.getServices(); assertNotNull(services); assertEquals(1, services.size()); Service service = (Service)services.get(new QName(qname, "XMLService")); assertNotNull(service); Map<?, ?> ports = service.getPorts(); assertNotNull(ports); assertEquals(1, ports.size()); Port port = service.getPort("XMLPort"); assertNotNull(port); assertEquals(1, port.getExtensibilityElements().size()); Object obj = port.getExtensibilityElements().get(0); if (obj instanceof JAXBExtensibilityElement) { obj = ((JAXBExtensibilityElement)obj).getValue(); } assertTrue(obj.getClass().getName() + " is not an AddressType", obj instanceof AddressType); Binding binding = port.getBinding(); assertNotNull(binding); assertEquals(new QName(qname, "Greeter_XMLBinding"), binding.getQName()); BindingOperation operation = binding.getBindingOperation("sayHi", null, null); assertNotNull(operation); BindingInput input = operation.getBindingInput(); assertNotNull(input); assertEquals(1, input.getExtensibilityElements().size()); obj = input.getExtensibilityElements().get(0); if (obj instanceof JAXBExtensibilityElement) { obj = ((JAXBExtensibilityElement)obj).getValue(); } assertTrue(obj.getClass().getName() + " is not an XMLBindingMessageFormat", obj instanceof XMLBindingMessageFormat); }