javax.wsdl.Port Java Examples

The following examples show how to use javax.wsdl.Port. 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: WSDL11ProcessorImpl.java    From carbon-apimgt with 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 #2
Source File: WSDLImporter.java    From activiti6-boot2 with 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 #3
Source File: SoapProtocol.java    From jolie with 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 #4
Source File: WSDLImporter.java    From activiti6-boot2 with 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 File: JAXBExtensionHelperTest.java    From cxf with 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 #6
Source File: WSDLImporter.java    From flowable-engine with 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 #7
Source File: WSDLImporter.java    From flowable-engine with 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 #8
Source File: WSDLManagerImplTest.java    From cxf with 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 #9
Source File: JAXBExtensionHelperTest.java    From cxf with 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 #10
Source File: SoapProtocol.java    From jolie with 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 #11
Source File: WSDLGetUtils.java    From cxf with 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 #12
Source File: WSDLDefinitionBuilderTest.java    From cxf with 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 #13
Source File: WSDLDefinitionBuilderTest.java    From cxf with 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 #14
Source File: WSDLToXMLProcessor.java    From cxf with 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 #15
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 #16
Source File: BPELPlanContext.java    From container with 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 #17
Source File: BPELPlanContext.java    From container with 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 #18
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 #19
Source File: WSDLRefValidator.java    From cxf with 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 #20
Source File: ODEEndpointUpdater.java    From container with 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 #21
Source File: ODEEndpointUpdater.java    From container with 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 #22
Source File: ODEEndpointUpdater.java    From container with 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 #23
Source File: ODEEndpointUpdater.java    From container with 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 #24
Source File: ManagementBusInvocationPluginSoapHttp.java    From container with Apache License 2.0 6 votes vote down vote up
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 #25
Source File: WSDL2UDDI.java    From juddi with 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 #26
Source File: WSDLToServiceProcessor.java    From cxf with 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 #27
Source File: AxisService.java    From tomee with Apache License 2.0 5 votes vote down vote up
private JaxRpcServiceInfo getJaxRpcServiceInfo(ClassLoader classLoader) throws OpenEJBException {
    JavaWsdlMapping mapping = null; // the java to wsdl mapping file
    CommonsSchemaInfoBuilder xmlBeansSchemaInfoBuilder = new CommonsSchemaInfoBuilder(null, null); // the schema data from the wsdl file
    PortComponent portComponent = null; // webservice.xml declaration of this service
    Port port = null; // wsdl.xml declaration of this service
    String wsdlFile = null;

    XmlSchemaInfo schemaInfo = xmlBeansSchemaInfoBuilder.createSchemaInfo();

    JaxRpcServiceInfoBuilder serviceInfoBuilder = new JaxRpcServiceInfoBuilder(mapping, schemaInfo, portComponent, port, wsdlFile, classLoader);
    JaxRpcServiceInfo serviceInfo = serviceInfoBuilder.createServiceInfo();
    return serviceInfo;
}
 
Example #28
Source File: WSDLToCorbaBindingTypeTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetCorbaAddressFile() throws Exception {

    try {
        URI fileName = getClass().getResource("/wsdl/datetime.wsdl").toURI();
        generator.setWsdlFile(new File(fileName).getAbsolutePath());
        generator.addInterfaceName("BasePortType");

        Definition model = generator.generateCORBABinding();
        QName name = new QName("http://schemas.apache.org/idl/datetime.idl",
                                 "BaseCORBAService", "tns");
        Service service = model.getService(name);
        Port port = service.getPort("BaseCORBAPort");
        AddressType addressType = (AddressType)port.getExtensibilityElements().get(0);
        String address = addressType.getLocation();
        assertEquals("file:./Base.ref", address);

        URL idl = getClass().getResource("/wsdl/addressfile.txt");
        String filename = new File(idl.toURI()).getAbsolutePath();
        generator.setAddressFile(filename);
        model = generator.generateCORBABinding();
        service = model.getService(name);
        port = service.getPort("BaseCORBAPort");
        addressType = (AddressType)port.getExtensibilityElements().get(0);
        address = addressType.getLocation();
        assertEquals("corbaloc::localhost:60000/hw", address);
    } finally {
        new File("datetime-corba.wsdl").deleteOnExit();
    }
}
 
Example #29
Source File: WSDLToCorbaBindingTypeTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetCorbaAddress() throws Exception {

    try {
        String fileName = getClass().getResource("/wsdl/datetime.wsdl").toString();
        generator.setWsdlFile(fileName);
        generator.addInterfaceName("BasePortType");

        Definition model = generator.generateCORBABinding();
        QName name = new QName("http://schemas.apache.org/idl/datetime.idl",
                                 "BaseCORBAService", "tns");
        Service service = model.getService(name);
        Port port = service.getPort("BaseCORBAPort");
        AddressType addressType = (AddressType)port.getExtensibilityElements().get(0);
        String address = addressType.getLocation();
        assertEquals("file:./Base.ref", address);

        generator.setAddress("corbaloc::localhost:40000/hw");
        model = generator.generateCORBABinding();
        service = model.getService(name);
        port = service.getPort("BaseCORBAPort");
        addressType = (AddressType)port.getExtensibilityElements().get(0);
        address = addressType.getLocation();
        assertEquals("corbaloc::localhost:40000/hw", address);
    } finally {
        new File("datetime-corba.wsdl").deleteOnExit();
    }
}
 
Example #30
Source File: WSDLRefValidator.java    From cxf with Apache License 2.0 5 votes vote down vote up
private XNode getXNode(Service service, Port port) {
    XNode vService = getXNode(service);

    XPort pNode = new XPort();
    pNode.setName(port.getName());
    pNode.setParentNode(vService);
    return pNode;
}