Java Code Examples for javax.wsdl.Service#setQName()
The following examples show how to use
javax.wsdl.Service#setQName() .
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: WSDLDocCreator.java From jolie with GNU Lesser General Public License v2.1 | 6 votes |
public Service createService( Definition localdef, String serviceName, Binding bind, String mySOAPAddress ) { Port p = localDef.createPort(); p.setName( serviceName + "Port" ); try { SOAPAddress soapAddress = (SOAPAddress) extensionRegistry.createExtension( Port.class, new QName( NameSpacesEnum.SOAP.getNameSpaceURI(), "address" ) ); soapAddress.setLocationURI( mySOAPAddress ); p.addExtensibilityElement( soapAddress ); } catch( WSDLException ex ) { ex.printStackTrace(); } p.setBinding( bind ); Service s = new ServiceImpl(); QName serviceQName = new QName( serviceName ); s.setQName( serviceQName ); s.addPort( p ); localDef.addService( s ); return s; }
Example 2
Source File: SimpleFileExporter.java From container with Apache License 2.0 | 4 votes |
private void rewriteServices(final Set<Mapping> servicesToRewrite, final WSDLWriter writer, final WSDLReader reader, final List<Path> referencedFiles) throws WSDLException, IOException { LOG.debug("Rewriting service names:"); LOG.debug("Files referenced:" + referencedFiles); LOG.debug("Services to rewrite:" + servicesToRewrite); for (final Mapping service : servicesToRewrite) { final QName serviceName = service.key; for (final Path file : referencedFiles) { if (!file.getFileName().toString().endsWith(".wsdl")) { continue; } final Definition def = reader.readWSDL(file.toAbsolutePath().toString()); final List<QName> servicesToRemove = new ArrayList<>(); boolean foundMatch = false; // fetch defined services for (final Object obj : def.getAllServices().values()) { final Service serviceA = (Service) obj; if (serviceName.equals(serviceA.getQName())) { // found wsdl with service we have to rewrite servicesToRemove.add(serviceA.getQName()); final Service newService = new ServiceImpl(); for (final Object o : serviceA.getPorts().values()) { final Port port = (Port) o; newService.addPort(port); } newService.setQName(service.val); def.addService(newService); foundMatch = true; } } if (foundMatch) { for (final QName serviceToRemove : servicesToRemove) { def.removeService(serviceToRemove); } writer.writeWSDL(def, Files.newOutputStream(file)); break; } } } }
Example 3
Source File: IDLToWSDLProcessor.java From cxf with Apache License 2.0 | 4 votes |
public void generateCORBAService(Definition def, Binding[] bindings, boolean isDefaultMapping) throws Exception { Map<String, Service> serviceMap = new HashMap<>(); Map<String, String> serviceNames = getServiceNames(bindings, isDefaultMapping); for (int i = 0; i < bindings.length; i++) { QName portTypeName = bindings[i].getPortType().getQName(); Service service; if (isDefaultMapping) { service = def.createService(); service.setQName(new QName(def.getTargetNamespace(), portTypeName.getLocalPart() + "CORBAService")); def.addService(service); } else { String ns = portTypeName.getNamespaceURI(); String serviceName = serviceNames.get(ns); service = serviceMap.get(ns); if (service == null) { service = def.createService(); serviceMap.put(ns, service); String[] serviceTokens = serviceName.split("\\."); String serviceToken = serviceTokens[serviceTokens.length - 1]; QName serviceQName = new QName(def.getTargetNamespace(), serviceToken); Service existingService = def.getService(serviceQName); if (existingService != null) { String existingServiceNS = ((Port) existingService.getPorts().values().iterator().next()) .getBinding().getPortType().getQName().getNamespaceURI(); existingService.setQName(new QName(def.getTargetNamespace(), serviceNames.get(existingServiceNS))); serviceMap.put(existingServiceNS, existingService); service.setQName(new QName(def.getTargetNamespace(), serviceName)); } else { service.setQName(serviceQName); } def.addService(service); } } Port port = def.createPort(); port.setName(portTypeName.getLocalPart() + "CORBAPort"); AddressType address = (AddressType) def.getExtensionRegistry().createExtension(Port.class, CorbaConstants.NE_CORBA_ADDRESS); String addr = null; String addrFileName = (String) env.get(ToolCorbaConstants.CFG_ADDRESSFILE); if (addrFileName != null) { File addrFile = new File(addrFileName); try { FileReader fileReader = new FileReader(addrFile); try (BufferedReader bufferedReader = new BufferedReader(fileReader)) { addr = bufferedReader.readLine(); } } catch (Exception ex) { throw new ToolException(ex.getMessage(), ex); } } else { addr = (String) env.get(ToolCorbaConstants.CFG_ADDRESS); } if (addr == null) { addr = "IOR:"; } address.setLocation(addr); port.addExtensibilityElement((ExtensibilityElement)address); service.addPort(port); port.setBinding(bindings[i]); } }
Example 4
Source File: ServiceWSDLBuilder.java From cxf with Apache License 2.0 | 4 votes |
protected void buildService(ServiceInfo serviceInfo, Definition definition) { Map<QName, MessageInfo> messages = serviceInfo.getMessages(); for (Map.Entry<QName, MessageInfo> mie : messages.entrySet()) { if (!mie.getKey().getNamespaceURI().equals(definition.getTargetNamespace())) { continue; } if (definition.getMessage(mie.getKey()) != null) { continue; } Message message = definition.createMessage(); addDocumentation(message, mie.getValue().getMessageDocumentation()); message.setUndefined(false); message.setQName(mie.getKey()); for (MessagePartInfo mpi : mie.getValue().getMessageParts()) { Part part = definition.createPart(); boolean elemental = mpi.isElement(); // RFSB will turn on isElement bogusly. if (elemental && null == serviceInfo.getXmlSchemaCollection(). getElementByQName(mpi.getElementQName())) { elemental = false; } if (elemental) { part.setElementName(mpi.getElementQName()); } else { part.setTypeName(mpi.getTypeQName()); } part.setName(mpi.getName().getLocalPart()); message.addPart(part); } definition.addMessage(message); } addDocumentation(definition, serviceInfo.getTopLevelDoc()); Service serv = definition.createService(); addDocumentation(serv, serviceInfo.getDocumentation()); serv.setQName(serviceInfo.getName()); addNamespace(serviceInfo.getName().getNamespaceURI(), definition); addExtensibilityElements(definition, serv, getWSDL11Extensors(serviceInfo)); definition.addService(serv); for (EndpointInfo ei : serviceInfo.getEndpoints()) { addNamespace(ei.getTransportId(), definition); Port port = definition.createPort(); addDocumentation(port, ei.getDocumentation()); port.setName(ei.getName().getLocalPart()); port.setBinding(definition.getBinding(ei.getBinding().getName())); addExtensibilityElements(definition, port, getWSDL11Extensors(ei)); serv.addPort(port); } }