Java Code Examples for javax.wsdl.Port

The following examples show how to use javax.wsdl.Port. These examples are extracted from open source projects. 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 Project: activiti6-boot2   Source File: WSDLImporter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Imports services and operations from the WSDL definition
 */
protected void importServicesAndOperations(Definition definition) {
  for (Object serviceObject : definition.getServices().values()) {
    Service service = (Service) serviceObject;
    WSService wsService = this.importService(service);
    this.wsServices.put(this.namespace + wsService.getName(), wsService);

    Port port = (Port) service.getPorts().values().iterator().next();
    for (Object bindOperationObject : port.getBinding().getBindingOperations()) {
      BindingOperation bindOperation = (BindingOperation) bindOperationObject;
      WSOperation operation = this.processOperation(bindOperation.getOperation(), wsService);
      wsService.addOperation(operation);

      this.wsOperations.put(this.namespace + operation.getName(), operation);
    }
  }
}
 
Example 2
Source Project: activiti6-boot2   Source File: WSDLImporter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Imports the service from the WSDL service definition
 */
protected WSService importService(Service service) {
  String name = service.getQName().getLocalPart();
  Port port = (Port) service.getPorts().values().iterator().next();
  String location = "";

  List extensionElements = port.getExtensibilityElements();
  for (Object extension : extensionElements) {
    if (extension instanceof SOAPAddress) {
      SOAPAddress address = (SOAPAddress) extension;
      location = address.getLocationURI();
    }
  }

  WSService wsService = new WSService(this.namespace + name, location, this.wsdlLocation);
  return wsService;
}
 
Example 3
Source Project: flowable-engine   Source File: WSDLImporter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Imports services and operations from the WSDL definition
 */
protected void importServicesAndOperations(Definition definition) {
    for (Object serviceObject : definition.getServices().values()) {
        Service service = (Service) serviceObject;
        WSService wsService = this.importService(service);
        this.wsServices.put(this.namespace + wsService.getName(), wsService);

        Port port = (Port) service.getPorts().values().iterator().next();
        for (Object bindOperationObject : port.getBinding().getBindingOperations()) {
            BindingOperation bindOperation = (BindingOperation) bindOperationObject;
            WSOperation operation = this.processOperation(bindOperation.getOperation(), wsService);
            wsService.addOperation(operation);

            this.wsOperations.put(this.namespace + operation.getName(), operation);
        }
    }
}
 
Example 4
Source Project: flowable-engine   Source File: WSDLImporter.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Imports the service from the WSDL service definition
 */
protected WSService importService(Service service) {
    String name = service.getQName().getLocalPart();
    Port port = (Port) service.getPorts().values().iterator().next();
    String location = "";

    List extensionElements = port.getExtensibilityElements();
    for (Object extension : extensionElements) {
        if (extension instanceof SOAPAddress) {
            SOAPAddress address = (SOAPAddress) extension;
            location = address.getLocationURI();
        }
    }

    WSService wsService = new WSService(this.namespace + name, location, this.wsdlLocation);
    return wsService;
}
 
Example 5
Source Project: jolie   Source File: SoapProtocol.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
private String getSoapActionForOperation( String operationName )
	throws IOException {
	String soapAction = null;
	Port port = getWSDLPort();
	if( port != null ) {
		BindingOperation bindingOperation = port.getBinding().getBindingOperation( operationName, null, null );
		for( ExtensibilityElement element : (List< ExtensibilityElement >) bindingOperation
			.getExtensibilityElements() ) {
			if( element instanceof SOAPOperation ) {
				soapAction = ((SOAPOperation) element).getSoapActionURI();
			}
		}
	}
	if( soapAction == null ) {
		soapAction = getStringParameter( "namespace" ) + "/" + operationName;
	}
	return soapAction;
}
 
Example 6
Source Project: jolie   Source File: SoapProtocol.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
private void setOutputEncodingStyle( SOAPEnvelope soapEnvelope, String operationName )
	throws IOException, SOAPException {
	Port port = getWSDLPort();
	if( port != null ) {
		BindingOperation bindingOperation = port.getBinding().getBindingOperation( operationName, null, null );
		if( bindingOperation == null ) {
			return;
		}
		BindingOutput output = bindingOperation.getBindingOutput();
		if( output == null ) {
			return;
		}
		for( ExtensibilityElement element : (List< ExtensibilityElement >) output.getExtensibilityElements() ) {
			if( element instanceof javax.wsdl.extensions.soap.SOAPBody ) {
				List< String > list = ((javax.wsdl.extensions.soap.SOAPBody) element).getEncodingStyles();
				if( list != null && list.isEmpty() == false ) {
					soapEnvelope.setEncodingStyle( list.get( 0 ) );
					soapEnvelope.addNamespaceDeclaration( "enc", list.get( 0 ) );
				}
			}
		}
	}
}
 
Example 7
Source Project: jolie   Source File: WSDLDocCreator.java    License: 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 8
Source Project: juddi   Source File: WSDL2UDDI.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Obtains the accessUrl from the WSDL
 *
 * @param port
 * @return a string url
 * @throws MalformedURLException
 */
private String getBindingURL(Port port) throws MalformedURLException {

        String bindingUrl = null;
        for (Object element : port.getExtensibilityElements()) {
                if (element instanceof SOAPAddress) {
                        SOAPAddress address = (SOAPAddress) element;
                        URL locationURI = new URL(address.getLocationURI());
                        if (locationURI != null) {
                                bindingUrl = urlLocalizer.rewrite(locationURI);
                                break;
                        }
                }
        }
        return bindingUrl;
}
 
Example 9
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 10
Source Project: container   Source File: ODEEndpointUpdater.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Checks whether the given Port is defined inside the given WSDL Definition
 *
 * @param port    the Port to check with as QName
 * @param wsdlDef the WSDL Definition to check in
 * @return true if the Port is found inside the given WSDL Definition, else false
 */
private boolean checkIfPortIsInWsdlDef(final QName port, final Definition wsdlDef) {
    for (final Object serviceObj : wsdlDef.getServices().values()) {
        final Service service = (Service) serviceObj;
        for (final Object portObj : service.getPorts().values()) {
            final Port wsdlPort = (Port) portObj;
            final String namespace = wsdlDef.getTargetNamespace();
            final String name = wsdlPort.getName();
            LOG.debug("Checking if port {} matches port with name {} and namespace {} ",
                port.toString(), name, namespace);
            if (name.equals(port.getLocalPart()) && namespace.equals(port.getNamespaceURI())) {
                return true;
            }
        }
    }
    return false;
}
 
Example 11
Source Project: container   Source File: ODEEndpointUpdater.java    License: Apache License 2.0 6 votes vote down vote up
private boolean updateProvidedWSDLAddresses(final QName portType, final File wsdlFile) throws WSDLException {
    boolean changed = false;
    final Definition wsdlDef = getWsdlReader().readWSDL(wsdlFile.getAbsolutePath());
    for (final Object o : wsdlDef.getAllServices().values()) {
        final Service service = (Service) o;
        for (final Object obj : service.getPorts().values()) {
            final Port port = (Port) obj;
            if (port.getBinding().getPortType().getQName().equals(portType)) {
                if (changePortAddressWithBpelEngineEndpoints(service, port)) {
                    changed = true;
                }
            }
        }
    }
    try {
        // if we changed something, rewrite the the wsdl
        if (changed) {
            this.factory.newWSDLWriter().writeWSDL(wsdlDef, new FileOutputStream(wsdlFile));
        }
    } catch (final FileNotFoundException e) {
        LOG.debug("Couldn't locate wsdl file", e);
        changed = false;
    }
    return changed;
}
 
Example 12
Source Project: container   Source File: ODEEndpointUpdater.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Changes address in the given port if endpoint in the endpoint service is available
 *
 * @param port the Port to update
 * @return true if change was made, else false
 */
private boolean changePortAddressWithEndpointDB(final Port port) {
    boolean changed = false;

    LOG.debug("Trying to match address element with available endpoints for port {} ",
        port.getName());
    for (final Object obj : port.getExtensibilityElements()) {
        // in the wsdl spec they use the extensibility mechanism
        final ExtensibilityElement element = (ExtensibilityElement) obj;
        for (final WSDLEndpoint endpoint : getWSDLEndpointsFromEndpointDB(port)) {
            LOG.debug("Changing address for endpoint: {}", endpoint.getURI());
            if (changeAddress(element, endpoint)) {
                changed = true;
            }
        }
    }
    return changed;
}
 
Example 13
Source Project: container   Source File: ODEEndpointUpdater.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns a list of WSDLEndpoints for the specific Port from the endpoint DB
 *
 * @param port the Port to check for
 * @return a list containing all WSDLEndpoints that matches the portTypes of the given Port
 */
private List<WSDLEndpoint> getWSDLEndpointsFromEndpointDB(final Port port) {
    final List<WSDLEndpoint> endpoints = new LinkedList<>();
    if (endpointService != null) {
        LOG.debug("Fetching Endpoints for PortType {} ",
            port.getBinding().getPortType().getQName().toString());
        final List<WSDLEndpoint> temp = endpointService.getWSDLEndpoints();
        for (final WSDLEndpoint endpoint : temp) {
            if (endpoint.getPortType().equals(port.getBinding().getPortType().getQName())
                && endpoint.getManagingContainer().equals(Settings.OPENTOSCA_CONTAINER_HOSTNAME)) {
                LOG.debug("Found endpoint: {}", endpoint.getURI().toString());
                endpoints.add(endpoint);
            }
        }
    } else {
        LOG.debug("Endpoint service not available");
    }
    LOG.debug("{} endpoints found for PortType {}", endpoints.size(), port.getBinding().getPortType().getQName().toString());
    return endpoints;
}
 
Example 14
Source Project: container   Source File: BPELPlanContext.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 15
Source Project: container   Source File: BPELPlanContext.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 16
Source Project: carbon-apimgt   Source File: WSDL11ProcessorImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 17
Source Project: j-road   Source File: XTeeSoapProvider.java    License: 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 18
Source Project: cxf   Source File: WSDLRefValidator.java    License: Apache License 2.0 6 votes vote down vote up
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 19
Source Project: cxf   Source File: WSDLToXMLProcessor.java    License: Apache License 2.0 6 votes vote down vote up
private void setAddrElement() throws ToolException {
    Address address = AddressFactory.getInstance().getAddresser("xml");

    for (Map.Entry<String, String> entry : address.getNamespaces(env).entrySet()) {
        wsdlDefinition.addNamespace(entry.getKey(), entry.getValue());
    }

    WSDLExtensibilityPlugin generator = getWSDLPlugin("xml", Port.class);
    try {
        ExtensibilityElement extElement = generator.createExtension(address.buildAddressArguments(env));

        port.addExtensibilityElement(extElement);
    } catch (WSDLException wse) {
        Message msg = new Message("FAIL_TO_CREATE_SOAPADDRESS", LOG);
        throw new ToolException(msg);
    }
}
 
Example 20
Source Project: cxf   Source File: WSDLToServiceProcessor.java    License: Apache License 2.0 6 votes vote down vote up
private void setAddrElement() throws ToolException {
    String transport = (String)env.get(ToolConstants.CFG_TRANSPORT);
    Address address = AddressFactory.getInstance().getAddresser(transport);

    Map<String, String> ns = address.getNamespaces(env);
    for (Map.Entry<String, String> entry : ns.entrySet()) {
        wsdlDefinition.addNamespace(entry.getKey(), entry.getValue());
    }

    WSDLExtensibilityPlugin plugin = getWSDLPlugin(transport, Port.class);
    try {
        ExtensibilityElement extElement = plugin.createExtension(address.buildAddressArguments(env));
        port.addExtensibilityElement(extElement);
    } catch (WSDLException wse) {
        Message msg = new Message("FAIL_TO_CREATE_SOAP_ADDRESS", LOG);
        throw new ToolException(msg, wse);
    }
}
 
Example 21
Source Project: cxf   Source File: WSDLDefinitionBuilderTest.java    License: Apache License 2.0 6 votes vote down vote up
@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 22
Source Project: cxf   Source File: WSDLDefinitionBuilderTest.java    License: Apache License 2.0 6 votes vote down vote up
@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 23
Source Project: cxf   Source File: WSDLGetUtils.java    License: Apache License 2.0 6 votes vote down vote up
protected void updatePublishedEndpointUrl(String publishingUrl,
                                          Definition def,
                                          QName name) {
    Collection<Service> services = CastUtils.cast(def.getAllServices().values());
    for (Service service : services) {
        Collection<Port> ports = CastUtils.cast(service.getPorts().values());
        if (ports.isEmpty()) {
            continue;
        }

        if (name == null) {
            setSoapAddressLocationOn(ports.iterator().next(), publishingUrl);
            break; // only update the first port since we don't target any specific port
        }
        for (Port port : ports) {
            if (name.getLocalPart().equals(port.getName())) {
                setSoapAddressLocationOn(port, publishingUrl);
            }
        }
    }
}
 
Example 24
Source Project: cxf   Source File: WSDLManagerImplTest.java    License: Apache License 2.0 6 votes vote down vote up
@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 25
Source Project: cxf   Source File: JAXBExtensionHelperTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testMappedNamespace() throws Exception {
    JAXBExtensionHelper.addExtensions(registry, javax.wsdl.Port.class,
        org.apache.cxf.abc.test.TestPolicyType.class,
        "http://cxf.apache.org/abc/test/remapped");

    JAXBExtensionHelper.addExtensions(registry, javax.wsdl.Port.class,
        org.apache.cxf.abc.test.AnotherPolicyType.class,
        "http://cxf.apache.org/abc/test/remapped");

    JAXBExtensionHelper.addExtensions(registry, javax.wsdl.Definition.class,
        org.apache.cxf.abc.test.NewServiceType.class,
        "http://cxf.apache.org/abc/test/remapped");

    String file = this.getClass().getResource("/wsdl/test_ext_remapped.wsdl").toURI().toString();
    wsdlReader.setExtensionRegistry(registry);

    wsdlDefinition = wsdlReader.readWSDL(file);
    checkTestExt();
    StringWriter out = new StringWriter();
    wsdlFactory.newWSDLWriter().writeWSDL(wsdlDefinition, out);
    wsdlDefinition = wsdlReader.readWSDL(null,
                                         new InputSource(new StringReader(out.toString())));
    checkTestExt();
}
 
Example 26
Source Project: cxf   Source File: JAXBExtensionHelperTest.java    License: Apache License 2.0 6 votes vote down vote up
private void checkTestExt() throws Exception {
    Service s = wsdlDefinition.getService(new QName("http://cxf.apache.org/test/hello_world",
        "HelloWorldService"));
    Port p = s.getPort("HelloWorldPort");
    List<?> extPortList = p.getExtensibilityElements();

    TestPolicyType tp = null;
    AnotherPolicyType ap = null;
    for (Object ext : extPortList) {
        if (ext instanceof TestPolicyType) {
            tp = (TestPolicyType) ext;
        } else if (ext instanceof AnotherPolicyType) {
            ap = (AnotherPolicyType) ext;
        } else if (ext instanceof UnknownExtensibilityElement) {
            UnknownExtensibilityElement e = (UnknownExtensibilityElement)ext;
            System.out.println(e.getElementType());
        }
    }
    assertNotNull("Could not find extension element TestPolicyType", tp);
    assertNotNull("Could not find extension element AnotherPolicyType", ap);

    assertEquals("Unexpected value for TestPolicyType intAttr", 30, tp.getIntAttr());
    assertEquals("Unexpected value for TestPolicyType stringAttr", "hello", tp.getStringAttr());
    assertTrue("Unexpected value for AnotherPolicyType floatAttr",
               Math.abs(0.1F - ap.getFloatAttr()) < 0.5E-5);
}
 
Example 27
Source Project: Tomcat8-Source-Read   Source File: ServiceRefFactory.java    License: MIT License 5 votes vote down vote up
/**
 * @param port analyzed port
 * @return Returns the endpoint URL of the given Port
 */
private String getSOAPLocation(Port port) {
    String endpoint = null;
    @SuppressWarnings("unchecked") // Can't change the API
    List<ExtensibilityElement> extensions = port.getExtensibilityElements();
    for (ExtensibilityElement ext : extensions) {
        if (ext instanceof SOAPAddress) {
            SOAPAddress addr = (SOAPAddress) ext;
            endpoint = addr.getLocationURI();
        }
    }
    return endpoint;
}
 
Example 28
Source Project: hop   Source File: WsdlUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get the SOAP address location for the specified port.
 *
 * @param p A WSDL Port instance.
 * @return The SOAP address URI.
 */
protected static String getSOAPAddress( Port p ) {
  ExtensibilityElement e = findExtensibilityElement( (ElementExtensible) p, SOAP_PORT_ADDRESS_NAME );
  if ( e instanceof SOAP12Address ) {
    return ( (SOAP12Address) e ).getLocationURI();
  } else if ( e instanceof SOAPAddress ) {
    return ( (SOAPAddress) e ).getLocationURI();
  }

  return null;
}
 
Example 29
Source Project: syndesis   Source File: SoapApiModelParser.java    License: Apache License 2.0 5 votes vote down vote up
private static List<BindingOperation> getBindingOperations(Definition definition, QName serviceName,
                                                           String portName) throws ParserException {
    final Service service = getService(definition, serviceName);
    final Port port = getPort(service, portName);
    @SuppressWarnings("unchecked")
    final List<BindingOperation> result = port.getBinding().getBindingOperations();
    return result;
}
 
Example 30
Source Project: pentaho-kettle   Source File: WsdlUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get the SOAP address location for the specified port.
 *
 * @param p
 *          A WSDL Port instance.
 * @return The SOAP address URI.
 */
protected static String getSOAPAddress( Port p ) {
  ExtensibilityElement e = findExtensibilityElement( p, SOAP_PORT_ADDRESS_NAME );
  if ( e instanceof SOAP12Address ) {
    return ( (SOAP12Address) e ).getLocationURI();
  } else if ( e instanceof SOAPAddress ) {
    return ( (SOAPAddress) e ).getLocationURI();
  }

  return null;
}