Java Code Examples for javax.wsdl.Definition#getAllPortTypes()

The following examples show how to use javax.wsdl.Definition#getAllPortTypes() . 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: BPEL2UDDITest.java    From juddi with Apache License 2.0 6 votes vote down vote up
@Test
public void testTN_BPEL4WSProcessTModel() throws WSDLException, JAXBException, Exception {

	// Obtained from the .bpel file:
	String targetNamespace = "http://example.com/travelagent";
	QName serviceName = new QName (targetNamespace, "ReservationAndBookingTickets");
	String bpelOverViewUrl = "http://localhost/registry/" + serviceName.getLocalPart() + ".bpel";
	
	// Reading the WSDL
	Definition wsdlDefinition = rw.readWSDL("bpel/bpel-technote.wsdl");
	
    @SuppressWarnings("unchecked")
	Map<QName,PortType> portTypes= (Map<QName,PortType>) wsdlDefinition.getAllPortTypes();
    TModel bpel4WSTModel = bpel2UDDI.createBPEL4WSProcessTModel(serviceName, targetNamespace, portTypes, bpelOverViewUrl);
    
	System.out.println("***** BPEL4WS Process TModel: " + bpel4WSTModel.getName().getValue());
               if (serialize)
	System.out.println(pTModel.print(bpel4WSTModel));
	
	Assert.assertNotNull(bpel4WSTModel);
}
 
Example 2
Source File: BPEL2UDDITest.java    From juddi with Apache License 2.0 6 votes vote down vote up
@Test
public void testHelloWorld_WSDLPortTypeModels() throws WSDLException, JAXBException , Exception{

	// Reading the WSDL
	Definition wsdlDefinition = rw.readWSDL("bpel/HelloWorld.wsdl");
    @SuppressWarnings("unchecked")
	Map<QName,PortType> portTypes= (Map<QName,PortType>) wsdlDefinition.getAllPortTypes();
    Set<TModel> portTypeTModels = bpel2UDDI.createWSDLPortTypeTModels(wsdlDefinition.getDocumentBaseURI(), portTypes);
    
	for (TModel tModel : portTypeTModels) {
		System.out.println("***** UDDI PortType TModel: " + tModel.getName().getValue());
                       if (serialize)
		System.out.println(pTModel.print(tModel));
	}
	Assert.assertEquals(1,portTypeTModels.size());
}
 
Example 3
Source File: BPEL2UDDITest.java    From juddi with Apache License 2.0 6 votes vote down vote up
@Test
public void testHelloWorld_BPEL4WSProcessTModel() throws WSDLException, JAXBException , Exception{

	//Obtained from the .bpel file:
	String targetNamespace = "http://www.jboss.org/bpel/examples";
	QName serviceName = new QName (targetNamespace, "HelloWorld");
	String bpelOverViewUrl = "http://localhost/registry/" + serviceName.getLocalPart() + ".bpel";
	
	// Reading the WSDL
	Definition wsdlDefinition = rw.readWSDL("bpel/HelloWorld.wsdl");
	
    @SuppressWarnings("unchecked")
	Map<QName,PortType> portTypes= (Map<QName,PortType>) wsdlDefinition.getAllPortTypes();
    TModel bpel4WSTModel = bpel2UDDI.createBPEL4WSProcessTModel(serviceName, targetNamespace, portTypes, bpelOverViewUrl);
    
	System.out.println("***** BPEL4WS Process TModel: " + bpel4WSTModel.getName().getValue());
               if (serialize)
	System.out.println(pTModel.print(bpel4WSTModel));
	
	Assert.assertNotNull(bpel4WSTModel);
}
 
Example 4
Source File: WSDL2UDDITest.java    From juddi with Apache License 2.0 6 votes vote down vote up
@Test
public void testUDDIBindingModel() throws WSDLException, JAXBException, ConfigurationException , Exception{

	// Reading the WSDL
	Definition wsdlDefinition = rw.readWSDL("wsdl/HelloWorld.wsdl");
	String wsdlURL = wsdlDefinition.getDocumentBaseURI();
	
	Properties properties = new Properties();
	properties.put("keyDomain", "juddi.apache.org");
	WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(null, new URLLocalizerDefaultImpl(), properties);
	Set<TModel> tModels = new HashSet<TModel>();
    @SuppressWarnings("unchecked")
	Map<QName,PortType> portTypes = (Map<QName,PortType>) wsdlDefinition.getAllPortTypes();
    Set<TModel> portTypeTModels = wsdl2UDDI.createWSDLPortTypeTModels(wsdlURL, portTypes);
    tModels.addAll(portTypeTModels);
    
	for (TModel tModel : tModels) {
		System.out.println("UDDI PortType TModel " + tModel.getName().getValue());
                       if (serialize)
		System.out.println(pTModel.print(tModel));
	}
	Assert.assertEquals(1,tModels.size());
}
 
Example 5
Source File: BPELPlanContext.java    From container with Apache License 2.0 6 votes vote down vote up
/**
 * Checks whether the given portType is declared in the given WSDL File
 *
 * @param portType the portType to check with
 * @param wsdlFile the WSDL File to check in
 * @return true if the portType is declared in the given WSDL file
 * @throws WSDLException is thrown when either the given File is not a WSDL File or initializing the WSDL Factory
 *                       failed
 */
public boolean containsPortType(final QName portType, final Path wsdlFile) throws WSDLException {
    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 portTypes = wsdlInstance.getAllPortTypes();
    for (final Object key : portTypes.keySet()) {
        final PortType portTypeInWsdl = (PortType) portTypes.get(key);
        if (portTypeInWsdl.getQName().getNamespaceURI().equals(portType.getNamespaceURI())
            && portTypeInWsdl.getQName().getLocalPart().equals(portType.getLocalPart())) {
            return true;
        }
    }
    return false;
}
 
Example 6
Source File: BPEL_020_IntegrationTest.java    From juddi with Apache License 2.0 5 votes vote down vote up
@Test
public void parseWSDL_PortTypeTModels() throws WSDLException, Exception {

        Definition wsdlDefinition = rw.readWSDL("uddi_data/bpel/riftsaw/bpel-technote.wsdl");
        @SuppressWarnings("unchecked")
        Map<QName, PortType> portTypes = (Map<QName, PortType>) wsdlDefinition.getAllPortTypes();
        String ns = wsdlDefinition.getTargetNamespace();
        logger.info("Namespace: " + ns);

        boolean foundInterfaceOfTravelAgent=false;
        boolean foundInterfaceOfCustomer=false;
  
        Iterator<QName> iterator = portTypes.keySet().iterator();
        while (iterator.hasNext()) {
                QName qName = iterator.next();
                String nsp = qName.getNamespaceURI();
                String localpart = qName.getLocalPart();
                logger.info("Namespace: " + nsp);
                logger.info("LocalPart: " + localpart);
                if (localpart.equals("InterfaceOfTravelAgent"))
                        foundInterfaceOfTravelAgent=true;
                if (localpart.equals("InterfaceOfCustomer"))
                        foundInterfaceOfCustomer=true;
        }
        org.junit.Assert.assertTrue("InterfaceOfCustomer wasn't found, wsdl parsing error", foundInterfaceOfCustomer);
        org.junit.Assert.assertTrue("InterfaceOfTravelAgent wasn't found, wsdl parsing error", foundInterfaceOfTravelAgent);
}
 
Example 7
Source File: WSDL2UDDI.java    From juddi with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public ServiceRegistrationResponse registerBusinessService(QName serviceQName, String portName, URL serviceUrl, Definition wsdlDefinition) throws RemoteException, ConfigurationException, TransportException, WSDLException, MalformedURLException {

        String genericWSDLURL = wsdlDefinition.getDocumentBaseURI();   //TODO maybe point to repository version
        ServiceRegistrationResponse response = new ServiceRegistrationResponse();
        String serviceKey = UDDIKeyConvention.getServiceKey(properties, serviceQName.getLocalPart());
        BusinessService businessService = lookupService(serviceKey);
        if (businessService == null) {
                List<TModel> tModels = new ArrayList<TModel>();
                // Create the PortType tModels
                Map<QName, PortType> portTypes = (Map<QName, PortType>) wsdlDefinition.getAllPortTypes();
                tModels.addAll(createWSDLPortTypeTModels(genericWSDLURL, portTypes));
                // Create the Binding tModels
                Map<QName, Binding> bindings = (Map<QName, Binding>) wsdlDefinition.getAllBindings();
                tModels.addAll(createWSDLBindingTModels(genericWSDLURL, bindings));
                // Register these tModels
                for (TModel tModel : tModels) {
                        clerk.register(tModel);
                }
                // Service
                businessService = createBusinessService(serviceQName, wsdlDefinition);
                // Register this Service
                clerk.register(businessService);
        }
        //Add the BindingTemplate to this Service
        BindingTemplate binding = createWSDLBinding(serviceQName, portName, serviceUrl, wsdlDefinition);
        // Register BindingTemplate
        if (binding.getAccessPoint() != null) {
                clerk.register(binding);
                if (businessService.getBindingTemplates() == null) {
                        businessService.setBindingTemplates(new BindingTemplates());
                }
                businessService.getBindingTemplates().getBindingTemplate().add(binding);
                response.setBindingKey(binding.getBindingKey());
        }
        response.setBusinessService(businessService);
        return response;
}
 
Example 8
Source File: BPEL2UDDI.java    From juddi with Apache License 2.0 5 votes vote down vote up
/**
 * 1. Register PortType tModels
 * 2. Register WSDL BPEL4WS Process
 * 3. Register WSDL Port
 * 4. Register Process Service
 * 5. Register Binding
 * 
 * @param serviceName - QName of the service
 * @param portName - portName of the service
 * @param serviceUrl - URL at which the service can be invoked
 * @param wsdlDefinition - WSDL Definition of the Web Service
        * @return a binding template
 * @throws WSDLException 
 * @throws MalformedURLException 
 * @throws TransportException 
 * @throws ConfigurationException 
 * @throws RemoteException 
 */
@SuppressWarnings("unchecked")
public BindingTemplate register(QName serviceName, String portName, URL serviceUrl, Definition wsdlDefinition) 
	throws WSDLException, MalformedURLException, RemoteException, ConfigurationException, TransportException 
{
	String targetNamespace = wsdlDefinition.getTargetNamespace();
	String genericWSDLURL  = wsdlDefinition.getDocumentBaseURI();   //TODO maybe point to repository version
	String bpelOverviewURL = "http://localhost:8080/bpel-console/"; //TODO maybe point to bpel in console
	
	String serviceKey = UDDIKeyConvention.getServiceKey(properties, serviceName.getLocalPart());
	BusinessService service = lookupService(serviceKey);
	if (service==null) {
		List<TModel> tModels = new ArrayList<TModel>();
		// Create the PortType tModels
		Map<QName,PortType> portTypes = (Map<QName,PortType>) wsdlDefinition.getAllPortTypes();
		tModels.addAll(createWSDLPortTypeTModels(genericWSDLURL, portTypes));
		// Create the Binding tModels
		Map<QName,Binding> bindings = (Map<QName,Binding>) wsdlDefinition.getAllBindings();
		tModels.addAll(createWSDLBindingTModels(genericWSDLURL, bindings));
		// Create the BPEL4WS tModel
		TModel bpel4WSTModel = createBPEL4WSProcessTModel(serviceName, targetNamespace, portTypes, bpelOverviewURL);
	    tModels.add(bpel4WSTModel);
	    // Register these tModels
	    for (TModel tModel : tModels) {
			clerk.register(tModel);
		}
	    // BPEL Service
	    service = createBusinessService(serviceName, wsdlDefinition);
	    // Register this BPEL Service
	    clerk.register(service);
	}
	//Add the BindingTemplate to this Service
	BindingTemplate binding = createBPELBinding(serviceName, portName, serviceUrl, wsdlDefinition);
	// Register BindingTemplate
	clerk.register(binding);
	return binding;
}
 
Example 9
Source File: BPEL2UDDITest.java    From juddi with Apache License 2.0 5 votes vote down vote up
@Test
public void testTN_WSDLPortTypeModels() throws WSDLException, JAXBException, Exception {

	// Reading the WSDL
	Definition wsdlDefinition = rw.readWSDL("bpel/bpel-technote.wsdl");
    @SuppressWarnings("unchecked")
	Map<QName,PortType> portTypes= (Map<QName,PortType>) wsdlDefinition.getAllPortTypes();
    Set<TModel> portTypeTModels = bpel2UDDI.createWSDLPortTypeTModels(wsdlDefinition.getDocumentBaseURI(), portTypes); 
    for (TModel tModel : portTypeTModels) {
		System.out.println("***** UDDI PortType TModel: " + tModel.getName().getValue());
                       if (serialize)
		System.out.println(pTModel.print(tModel));
	}
	Assert.assertEquals(2,portTypeTModels.size());
}