Java Code Examples for javax.wsdl.Port#addExtensibilityElement()

The following examples show how to use javax.wsdl.Port#addExtensibilityElement() . 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 vote down vote up
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: XTeeSoapProvider.java    From j-road with Apache License 2.0 6 votes vote down vote up
@Override
protected void populatePort(Definition definition, Port port) throws WSDLException {
  super.populatePort(definition, port);
  ExtensionRegistry extensionRegistry = definition.getExtensionRegistry();
  extensionRegistry.mapExtensionTypes(Port.class,
                                      new QName(XTeeWsdlDefinition.XROAD_NAMESPACE,
                                                "address",
                                                XTeeWsdlDefinition.XROAD_PREFIX),
                                      UnknownExtensibilityElement.class);
  UnknownExtensibilityElement element =
      (UnknownExtensibilityElement) extensionRegistry.createExtension(Port.class,
                                                                      new QName(XTeeWsdlDefinition.XROAD_NAMESPACE,
                                                                                "address",
                                                                                XTeeWsdlDefinition.XROAD_NAMESPACE));
  Document doc;
  try {
    doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
  } catch (ParserConfigurationException e) {
    throw new RuntimeException(e);
  }
  Element xRoadAddr = doc.createElementNS(XTeeWsdlDefinition.XROAD_NAMESPACE, "address");
  xRoadAddr.setPrefix(XTeeWsdlDefinition.XROAD_PREFIX);
  xRoadAddr.setAttribute("producer", xRoadDatabase);
  element.setElement(xRoadAddr);
  port.addExtensibilityElement(element);
}
 
Example 3
Source File: PartialWSDLProcessor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static javax.wsdl.Service doAppendService(Definition wsdlDefinition,
                                                 String existPortName, ExtensionRegistry
                                                 extReg, Binding binding) throws Exception {
    javax.wsdl.Service wsdlService = wsdlDefinition.createService();
    wsdlService.setQName(new QName(wsdlDefinition.getTargetNamespace(), existPortName + serviceName));
    Port port = wsdlDefinition.createPort();
    port.setName(existPortName + portName);
    port.setBinding(binding);
    SOAPAddress address = PartialWSDLProcessor.setAddrElement(wsdlDefinition, port, extReg);
    port.addExtensibilityElement(address);
    wsdlService.addPort(port);
    return wsdlService;
}
 
Example 4
Source File: IDLToWSDLProcessor.java    From cxf with Apache License 2.0 4 votes vote down vote up
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]);
    }
}