Java Code Examples for javax.wsdl.Binding#getPortType()
The following examples show how to use
javax.wsdl.Binding#getPortType() .
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: Wsdl.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/** * Find the specified operation in the WSDL definition. * * @param operationName * Name of operation to find. * @return A WsdlOperation instance, null if operation can not be found in WSDL. */ public WsdlOperation getOperation( String operationName ) throws KettleStepException { // is the operation in the cache? if ( _operationCache.containsKey( operationName ) ) { return _operationCache.get( operationName ); } Binding b = _port.getBinding(); PortType pt = b.getPortType(); Operation op = pt.getOperation( operationName, null, null ); if ( op != null ) { try { WsdlOperation wop = new WsdlOperation( b, op, _wsdlTypes ); // cache the operation _operationCache.put( operationName, wop ); return wop; } catch ( KettleException kse ) { LogChannel.GENERAL.logError( "Could not retrieve WSDL Operator for operation name: " + operationName ); throw new KettleStepException( "Could not retrieve WSDL Operator for operation name: " + operationName, kse ); } } return null; }
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: WSIBPValidator.java From cxf with Apache License 2.0 | 5 votes |
public boolean checkR2205() { Collection<Binding> bindings = CastUtils.cast(def.getBindings().values()); for (Binding binding : bindings) { if (!SOAPBindingUtil.isSOAPBinding(binding)) { System.err.println("WSIBP Validator found <" + binding.getQName() + "> is NOT a SOAP binding"); continue; } if (binding.getPortType() == null) { //will error later continue; } for (Iterator<?> ite2 = binding.getPortType().getOperations().iterator(); ite2.hasNext();) { Operation operation = (Operation)ite2.next(); Collection<Fault> faults = CastUtils.cast(operation.getFaults().values()); if (CollectionUtils.isEmpty(faults)) { continue; } for (Fault fault : faults) { Message message = fault.getMessage(); Collection<Part> parts = CastUtils.cast(message.getParts().values()); for (Part part : parts) { if (part.getElementName() == null) { addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2205") + "In Message " + message.getQName() + ", part " + part.getName() + " must specify a 'element' attribute"); return false; } } } } } return true; }
Example 4
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 5
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 6
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 7
Source File: WSDLRefValidator.java From cxf with Apache License 2.0 | 4 votes |
private void collectValidationPointsForBindings() throws Exception { Map<QName, XNode> vBindingNodes = new HashMap<>(); for (Service service : services.values()) { vBindingNodes.putAll(getBindings(service)); } for (Map.Entry<QName, XNode> entry : vBindingNodes.entrySet()) { QName bName = entry.getKey(); Binding binding = this.definition.getBinding(bName); if (binding == null) { LOG.log(Level.SEVERE, bName.toString() + " is not correct, please check that the correct namespace is being used"); throw new Exception(bName.toString() + " is not correct, please check that the correct namespace is being used"); } XNode vBindingNode = getXNode(binding); vBindingNode.setFailurePoint(entry.getValue()); vNodes.add(vBindingNode); if (binding.getPortType() == null) { continue; } portTypeRefNames.add(binding.getPortType().getQName()); XNode vPortTypeNode = getXNode(binding.getPortType()); vPortTypeNode.setFailurePoint(vBindingNode); vNodes.add(vPortTypeNode); Collection<BindingOperation> bops = CastUtils.cast(binding.getBindingOperations()); for (BindingOperation bop : bops) { XNode vOpNode = getOperationXNode(vPortTypeNode, bop.getName()); XNode vBopNode = getOperationXNode(vBindingNode, bop.getName()); vOpNode.setFailurePoint(vBopNode); vNodes.add(vOpNode); if (bop.getBindingInput() != null) { String inName = bop.getBindingInput().getName(); if (!StringUtils.isEmpty(inName)) { XNode vInputNode = getInputXNode(vOpNode, inName); vInputNode.setFailurePoint(getInputXNode(vBopNode, inName)); vNodes.add(vInputNode); } } if (bop.getBindingOutput() != null) { String outName = bop.getBindingOutput().getName(); if (!StringUtils.isEmpty(outName)) { XNode vOutputNode = getOutputXNode(vOpNode, outName); vOutputNode.setFailurePoint(getOutputXNode(vBopNode, outName)); vNodes.add(vOutputNode); } } for (Iterator<?> iter1 = bop.getBindingFaults().keySet().iterator(); iter1.hasNext();) { String faultName = (String) iter1.next(); XNode vFaultNode = getFaultXNode(vOpNode, faultName); vFaultNode.setFailurePoint(getFaultXNode(vBopNode, faultName)); vNodes.add(vFaultNode); } } } }
Example 8
Source File: WSDLServiceBuilder.java From cxf with Apache License 2.0 | 4 votes |
public List<ServiceInfo> buildMockServices(Definition d) { List<ServiceInfo> serviceList = new ArrayList<>(); List<Definition> defList = new ArrayList<>(); defList.add(d); parseImports(d, defList); for (Definition def : defList) { for (Iterator<?> ite = def.getPortTypes().entrySet().iterator(); ite.hasNext();) { Entry<?, ?> entry = (Entry<?, ?>)ite.next(); PortType portType = def.getPortType((QName)entry.getKey()); ServiceInfo serviceInfo = this.buildMockService(def, portType); serviceList.add(serviceInfo); for (Iterator<?> it2 = d.getAllBindings().values().iterator(); it2.hasNext();) { Binding b = (Binding)it2.next(); if (b.getPortType() == portType) { this.buildBinding(serviceInfo, b); break; } } } if (def.getPortTypes().isEmpty()) { DescriptionInfo description = new DescriptionInfo(); if (recordOriginal) { description.setProperty(WSDL_DEFINITION, def); } description.setName(def.getQName()); description.setBaseURI(def.getDocumentBaseURI()); copyExtensors(description, def.getExtensibilityElements()); copyExtensionAttributes(description, def); ServiceInfo service = new ServiceInfo(); service.setDescription(description); if (recordOriginal) { service.setProperty(WSDL_DEFINITION, def); } getSchemas(def, service); service.setProperty(WSDL_SCHEMA_ELEMENT_LIST, this.schemaList); serviceList.add(service); } } return serviceList; }
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(); } }