Java Code Examples for javax.wsdl.Port#getBinding()
The following examples show how to use
javax.wsdl.Port#getBinding() .
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: WSDLRefValidator.java From cxf with Apache License 2.0 | 6 votes |
private Map<QName, XNode> getBindings(Service service) { Map<QName, XNode> bindings = new HashMap<>(); if (service.getPorts().values().isEmpty()) { throw new ToolException("Service " + service.getQName() + " does not contain any usable ports"); } Collection<Port> ports = CastUtils.cast(service.getPorts().values()); for (Port port : ports) { Binding binding = port.getBinding(); bindings.put(binding.getQName(), getXNode(service, port)); if (WSDLConstants.NS_WSDL11.equals(binding.getQName().getNamespaceURI())) { throw new ToolException("Binding " + binding.getQName().getLocalPart() + " namespace set improperly."); } } return bindings; }
Example 2
Source File: WSDLUtils.java From tesb-studio-se with Apache License 2.0 | 5 votes |
public static boolean isOperationInBinding(Definition definition, String portTypeName, String operationName) throws CoreException { Collection<?> services = definition.getServices().values(); for (Object s : services) { Service service = (Service) s; Collection<?> ports = service.getPorts().values(); for (Object p : ports) { Port port = (Port) p; Binding binding = port.getBinding(); if (binding == null) { continue; } PortType portType = binding.getPortType(); if (portType == null || !portTypeName.equals(portType.getQName().getLocalPart())) { continue; } List<?> bindingOperations = binding.getBindingOperations(); for (Object o : bindingOperations) { BindingOperation bo = (BindingOperation) o; if (operationName.equals(bo.getName())) { return true; } } } } return false; }
Example 3
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 4
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 5
Source File: SoapApiConnectorGenerator.java From syndesis with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private Connector createConnector(ConnectorTemplate connectorTemplate, ConnectorSettings connectorSettings, SoapApiModelInfo modelInfo) { final Definition definition = modelInfo.getModel(). orElseThrow(() -> new IllegalArgumentException("Unable to parse WSDL, or missing SOAP Service and Port in specification")); // get service and port final Map<String, String> configuredProperties = connectorSettings.getConfiguredProperties(); final QName serviceName = getService(modelInfo, configuredProperties) .orElseThrow(() -> new IllegalArgumentException("Missing property " + SERVICE_NAME_PROPERTY)); final String portName = getPortName(modelInfo, configuredProperties) .orElseThrow(() -> new IllegalArgumentException("Missing property " + PORT_NAME_PROPERTY)); // get SOAP Version from Service and Port final Service service = definition.getService(serviceName); final Port port = service.getPort(portName); final Binding binding = port.getBinding(); double soapVersion = 1.1; for (Object element : binding.getExtensibilityElements()) { if (element instanceof SOAP12Binding) { soapVersion = 1.2; break; } } // add actions try { final Connector configuredConnector = configuredConnector(connectorTemplate, connectorSettings); final List<ConnectorAction> actions = SoapApiModelParser.parseActions(definition, serviceName, new QName(serviceName.getNamespaceURI(), portName), configuredConnector.getId().get()); final ActionsSummary actionsSummary = SoapApiModelParser.parseActionsSummary(definition, serviceName, portName); final Connector.Builder builder = new Connector.Builder() .createFrom(configuredConnector) .putConfiguredProperty(SOAP_VERSION_PROPERTY, String.valueOf(soapVersion)) .addAllActions(actions) .actionsSummary(actionsSummary); return builder.build(); } catch (ParserException e) { throw new IllegalArgumentException("Error getting actions from WSDL: " + e.getMessage(), e); } }
Example 6
Source File: ComponentBuilder.java From tesb-studio-se with Apache License 2.0 | 4 votes |
private static ServiceInfo populateComponent(Service service) { ServiceInfo serviceInfo = new ServiceInfo(); serviceInfo.setServiceName(service.getQName()); Collection<Port> ports = service.getPorts().values(); for (Port port : ports) { String soapLocation = null; SOAPAddress soapAddress = findExtensibilityElement(port.getExtensibilityElements(), SOAPAddress.class); if (null != soapAddress) { soapLocation = soapAddress.getLocationURI(); } else { SOAP12Address soap12Address = findExtensibilityElement(port.getExtensibilityElements(), SOAP12Address.class); if (null != soap12Address) { soapLocation = soap12Address.getLocationURI(); } } Binding binding = port.getBinding(); for (BindingOperation operation : (Collection<BindingOperation>) binding.getBindingOperations()) { SOAPOperation soapOperation = findExtensibilityElement(operation.getExtensibilityElements(), SOAPOperation.class); if (null != soapOperation && OPERATION_TYPE_RPC.equalsIgnoreCase(soapOperation.getStyle())) { // TESB-6151 disable display of unsupported RPC type. serviceInfo.setHasRpcOperation(true); continue; } OperationInfo operationInfo = new OperationInfo(operation.getOperation()); operationInfo.setPortName(port.getName()); operationInfo.setNamespaceURI(binding.getPortType().getQName().getNamespaceURI()); if (soapOperation != null) { operationInfo.setSoapActionURI(soapOperation.getSoapActionURI()); } else { SOAP12Operation soap12Operation = findExtensibilityElement(operation.getExtensibilityElements(), SOAP12Operation.class); if (soap12Operation != null) { operationInfo.setSoapActionURI(soap12Operation.getSoapActionURI()); } } operationInfo.setTargetURL(soapLocation); serviceInfo.addOperation(operationInfo); } } return serviceInfo; }
Example 7
Source File: BPEL2UDDI.java From juddi with Apache License 2.0 | 4 votes |
public BindingTemplate createBPELBinding(QName serviceName, String portName, URL serviceUrl, Definition wsdlDefinition) { BindingTemplate bindingTemplate = new BindingTemplate(); // Set BusinessService Key bindingTemplate.setServiceKey(UDDIKeyConvention.getServiceKey(properties, serviceName.getLocalPart())); // Set Binding Key String bindingKey = UDDIKeyConvention.getBindingKey(properties, serviceName, portName, serviceUrl); bindingTemplate.setBindingKey(bindingKey); // Set AccessPoint AccessPoint accessPoint = new AccessPoint(); accessPoint.setUseType(AccessPointType.END_POINT.toString()); accessPoint.setValue(urlLocalizer.rewrite(serviceUrl)); bindingTemplate.setAccessPoint(accessPoint); Service service = wsdlDefinition.getService(serviceName); if (service!=null) { TModelInstanceDetails tModelInstanceDetails = new TModelInstanceDetails(); Port port = service.getPort(portName); if (port!=null) { Binding binding = port.getBinding(); // Set the Binding Description String bindingDescription = properties.getProperty(Property.BINDING_DESCRIPTION, Property.DEFAULT_BINDING_DESCRIPTION); // Override with the service description from the WSDL if present Element docElement = binding.getDocumentationElement(); if (docElement!=null && docElement.getTextContent()!=null) { bindingDescription = docElement.getTextContent(); } bindingTemplate.getDescription().addAll(Common2UDDI.mapDescription(bindingDescription, lang)); // reference wsdl:binding tModel TModelInstanceInfo tModelInstanceInfoBinding = new TModelInstanceInfo(); tModelInstanceInfoBinding.setTModelKey(keyDomainURI + binding.getQName().getLocalPart()); InstanceDetails instanceDetails = new InstanceDetails(); instanceDetails.setInstanceParms(portName); tModelInstanceInfoBinding.setInstanceDetails(instanceDetails); tModelInstanceInfoBinding.getDescription().addAll(Common2UDDI.mapDescription("The wsdl:binding that this wsdl:port implements. " + bindingDescription + " The instanceParms specifies the port local name.", lang)); tModelInstanceDetails.getTModelInstanceInfo().add(tModelInstanceInfoBinding); // reference wsdl:portType tModel PortType portType = binding.getPortType(); TModelInstanceInfo tModelInstanceInfoPortType = new TModelInstanceInfo(); tModelInstanceInfoPortType.setTModelKey(keyDomainURI + portType.getQName().getLocalPart()); String portTypeDescription = ""; docElement = portType.getDocumentationElement(); if (docElement!=null && docElement.getTextContent()!=null) { portTypeDescription = docElement.getTextContent(); } tModelInstanceInfoPortType.getDescription().addAll(Common2UDDI.mapDescription("The wsdl:portType that this wsdl:port implements." + portTypeDescription, lang)); tModelInstanceDetails.getTModelInstanceInfo().add(tModelInstanceInfoPortType); //reference bpel:process tModel TModelInstanceInfo tModelInstanceInfoBPEL = new TModelInstanceInfo(); tModelInstanceInfoBPEL.setTModelKey(keyDomainURI + service.getQName().getLocalPart() + "Process"); // Description String serviceDescription = properties.getProperty(Property.SERVICE_DESCRIPTION, Property.DEFAULT_SERVICE_DESCRIPTION); // Override with the service description from the WSDL if present docElement = wsdlDefinition.getService(serviceName).getDocumentationElement(); if (docElement!=null && docElement.getTextContent()!=null) { serviceDescription = docElement.getTextContent(); } tModelInstanceInfoBPEL.getDescription().addAll(Common2UDDI.mapDescription("The bpel:process this wsdl:port supports." + serviceDescription, lang)); tModelInstanceDetails.getTModelInstanceInfo().add(tModelInstanceInfoBPEL); bindingTemplate.setTModelInstanceDetails(tModelInstanceDetails); } else { log.error("Could not find Port with portName: " + portName); } } else { log.error("Could not find Service with serviceName: " + serviceName.getLocalPart()); } if (log.isDebugEnabled()) { log.debug(new PrintUDDI<BindingTemplate>().print(bindingTemplate)); } return bindingTemplate; }
Example 8
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); }
Example 9
Source File: WsdlVisitor.java From tomee with Apache License 2.0 | 4 votes |
public void walkTree() { begin(); try { visit(definition); for (Iterator iterator = definition.getImports().entrySet().iterator(); iterator.hasNext(); ) { Map.Entry entry = (Map.Entry) iterator.next(); String namespaceURI = (String) entry.getKey(); List importsForNamespace = (List) entry.getValue(); for (Iterator iterator1 = importsForNamespace.iterator(); iterator1.hasNext(); ) { Import anImport = (Import) iterator1.next(); visit(anImport); } } visit(definition.getTypes()); Collection messages = definition.getMessages().values(); for (Iterator iterator = messages.iterator(); iterator.hasNext(); ) { Message message = (Message) iterator.next(); visit(message); Collection parts = message.getParts().values(); for (Iterator iterator2 = parts.iterator(); iterator2.hasNext(); ) { Part part = (Part) iterator2.next(); visit(part); } } Collection services = definition.getServices().values(); for (Iterator iterator = services.iterator(); iterator.hasNext(); ) { Service service = (Service) iterator.next(); visit(service); Collection ports = service.getPorts().values(); for (Iterator iterator1 = ports.iterator(); iterator1.hasNext(); ) { Port port = (Port) iterator1.next(); visit(port); Binding binding = port.getBinding(); visit(binding); List bindingOperations = binding.getBindingOperations(); for (int i = 0; i < bindingOperations.size(); i++) { BindingOperation bindingOperation = (BindingOperation) bindingOperations.get(i); visit(bindingOperation); visit(bindingOperation.getBindingInput()); visit(bindingOperation.getBindingOutput()); Collection bindingFaults = bindingOperation.getBindingFaults().values(); for (Iterator iterator2 = bindingFaults.iterator(); iterator2.hasNext(); ) { BindingFault bindingFault = (BindingFault) iterator2.next(); visit(bindingFault); } } PortType portType = binding.getPortType(); visit(portType); List operations = portType.getOperations(); for (int i = 0; i < operations.size(); i++) { Operation operation = (Operation) operations.get(i); visit(operation); { Input input = operation.getInput(); visit(input); } { Output output = operation.getOutput(); visit(output); } Collection faults = operation.getFaults().values(); for (Iterator iterator2 = faults.iterator(); iterator2.hasNext(); ) { Fault fault = (Fault) iterator2.next(); visit(fault); } } } } } catch (Exception e) { LOGGER.error(e.getMessage(), e); } finally { end(); } }