javax.wsdl.PortType Java Examples

The following examples show how to use javax.wsdl.PortType. 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: Wsdl.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Get a list of all operations defined in this WSDL.
 *
 * @return List of WsdlOperations.
 */
@SuppressWarnings( "unchecked" )
public List<WsdlOperation> getOperations() throws KettleStepException {

  List<WsdlOperation> opList = new ArrayList<WsdlOperation>();
  PortType pt = _port.getBinding().getPortType();

  List<Operation> operations = pt.getOperations();
  for ( Iterator<Operation> itr = operations.iterator(); itr.hasNext(); ) {
    WsdlOperation operation = getOperation( itr.next().getName() );
    if ( operation != null ) {
      opList.add( operation );
    }
  }
  return opList;
}
 
Example #2
Source File: ServiceWSDLBuilder.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void buildBinding(Definition definition,
                            Collection<BindingInfo> bindingInfos,
                            Collection<PortType> portTypes) {
    Binding binding = null;
    for (BindingInfo bindingInfo : bindingInfos) {
        binding = definition.createBinding();
        addDocumentation(binding, bindingInfo.getDocumentation());
        binding.setUndefined(false);
        for (PortType portType : portTypes) {
            if (portType.getQName().equals(bindingInfo.getInterface().getName())) {
                binding.setPortType(portType);
                break;
            }
        }
        binding.setQName(bindingInfo.getName());
        if (!bindingInfo.getName().getNamespaceURI().equals(definition.getTargetNamespace())) {
            addNamespace(bindingInfo.getName().getNamespaceURI(), definition);
        }
        buildBindingOperation(definition, binding, bindingInfo.getOperations());
        addExtensibilityElements(definition, binding, getWSDL11Extensors(bindingInfo));
        definition.addBinding(binding);
    }
}
 
Example #3
Source File: ServiceWSDLBuilder.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected PortType buildPortType(InterfaceInfo intf, final Definition def) {
    PortType portType = null;
    try {
        portType = intf.getProperty(WSDLServiceBuilder.WSDL_PORTTYPE, PortType.class);
    } catch (ClassCastException e) {
        // do nothing
    }

    if (portType == null) {
        portType = def.createPortType();
        portType.setQName(intf.getName());
        addDocumentation(portType, intf.getDocumentation());
        addNamespace(intf.getName().getNamespaceURI(), def);
        addExtensibilityElements(def, portType, getWSDL11Extensors(intf));
        addExtensibilityAttributes(def, portType, intf.getExtensionAttributes());
        portType.setUndefined(false);
        buildPortTypeOperation(portType, intf.getOperations(), def);
    }

    def.addPortType(portType);
    return portType;
}
 
Example #4
Source File: WSDLServiceBuilder.java    From cxf with Apache License 2.0 6 votes vote down vote up
public ServiceInfo buildMockService(Definition def, PortType p) {
    DescriptionInfo description = new DescriptionInfo();
    if (recordOriginal) {
        description.setProperty(WSDL_DEFINITION, def);
    }
    description.setName(def.getQName());
    description.setBaseURI(def.getDocumentBaseURI());
    copyExtensors(description, def.getExtensibilityElements());
    copyExtensionAttributes(description, def);

    ServiceInfo service = new ServiceInfo();
    service.setDescription(description);
    if (recordOriginal) {
        service.setProperty(WSDL_DEFINITION, def);
    }
    getSchemas(def, service);

    service.setProperty(WSDL_SCHEMA_ELEMENT_LIST, this.schemaList);

    buildInterface(service, p);

    return service;
}
 
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: WSDLServiceBuilder.java    From cxf with Apache License 2.0 6 votes vote down vote up
public void buildInterface(ServiceInfo si, PortType p) {
    InterfaceInfo inf = si.createInterface(p.getQName());
    DescriptionInfo d = si.getDescription();
    if (null != d) {
        d.getDescribed().add(inf);
    }
    copyDocumentation(inf, p);
    this.copyExtensors(inf, p.getExtensibilityElements());
    this.copyExtensionAttributes(inf, p);
    if (recordOriginal) {
        inf.setProperty(WSDL_PORTTYPE, p);
    }
    for (Operation op : cast(p.getOperations(), Operation.class)) {
        buildInterfaceOperation(inf, op);
    }

}
 
Example #7
Source File: PartialWSDLProcessor.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static boolean isPortTypeExisted(Definition wsdlDefinition, QName name) {
    Map<QName, PortType>  portTypes = CastUtils.cast(wsdlDefinition.getAllPortTypes());
    if (portTypes == null || portTypes.isEmpty()) {
        return false;
    }
    String existPortTypeName = null;
    PortType portType = null;
    try {
        for (Entry<QName, PortType> entry : portTypes.entrySet()) {
            existPortTypeName = entry.getKey().getLocalPart();
            if (name.getLocalPart().contains(existPortTypeName)) {
                portType = entry.getValue();
                break;
            }
        }
    } catch (Exception e) {
        portType = null;
    }
    return portType != null;
}
 
Example #8
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 #9
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 #10
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 #11
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 #12
Source File: PartialWSDLProcessor.java    From cxf with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private static void addBindingOperation(Definition wsdlDefinition, PortType portType, Binding binding,
                                        ExtensionRegistry extReg) throws Exception {
    List<Operation> ops = portType.getOperations();
    for (Operation op : ops) {
        BindingOperation bindingOperation = wsdlDefinition.createBindingOperation();
        setSoapOperationExtElement(bindingOperation, extReg);
        bindingOperation.setName(op.getName());
        if (op.getInput() != null) {
            bindingOperation.setBindingInput(getBindingInput(op.getInput(), wsdlDefinition, extReg));
        }
        if (op.getOutput() != null) {
            bindingOperation.setBindingOutput(getBindingOutput(op.getOutput(), wsdlDefinition, extReg));
        }
        if (op.getFaults() != null && op.getFaults().size() > 0) {
            addSoapFaults(op, bindingOperation, wsdlDefinition, extReg);
        }
        bindingOperation.setOperation(op);
        binding.addBindingOperation(bindingOperation);
    }
}
 
Example #13
Source File: ServiceWSDLBuilderTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testGreetMeOneWayOperation() throws Exception {
    setupWSDL(WSDL_PATH);
    PortType portType = newDef.getPortType(new QName(newDef.getTargetNamespace(),
        "Greeter"));
    Operation greetMeOneWay = portType.getOperation("greetMeOneWay", "greetMeOneWayRequest", null);
    assertNotNull(greetMeOneWay);
    assertEquals("greetMeOneWay", greetMeOneWay.getName());
    Input input = greetMeOneWay.getInput();
    assertNotNull(input);
    assertEquals("greetMeOneWayRequest", input.getName());
    Message message = input.getMessage();
    assertNotNull(message);
    assertEquals("greetMeOneWayRequest", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("in", message.getPart("in").getName());
    Output output = greetMeOneWay.getOutput();
    assertNull(output);
    assertEquals(0, greetMeOneWay.getFaults().size());
}
 
Example #14
Source File: WSDLDocCreator.java    From jolie with GNU Lesser General Public License v2.1 6 votes vote down vote up
private Binding createBindingSOAP( Definition def, PortType pt, String bindingName ) {
	Binding bind = def.getBinding( new QName( bindingName ) );
	if( bind == null ) {
		bind = def.createBinding();
		bind.setQName( new QName( tns, bindingName ) );
	}
	bind.setPortType( pt );
	bind.setUndefined( false );
	try {
		SOAPBinding soapBinding = (SOAPBinding) extensionRegistry.createExtension( Binding.class,
			new QName( NameSpacesEnum.SOAP.getNameSpaceURI(), "binding" ) );
		soapBinding.setTransportURI( NameSpacesEnum.SOAP_OVER_HTTP.getNameSpaceURI() );
		soapBinding.setStyle( "document" );
		bind.addExtensibilityElement( soapBinding );
	} catch( WSDLException ex ) {
		System.err.println( ex.getMessage() );
	}
	def.addBinding( bind );

	return bind;

}
 
Example #15
Source File: Wsdl.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Find the specified operation in the WSDL definition.
 *
 * @param operationName
 *          Name of operation to find.
 * @return A WsdlOperation instance, null if operation can not be found in WSDL.
 */
public WsdlOperation getOperation( String operationName ) throws KettleStepException {

  // is the operation in the cache?
  if ( _operationCache.containsKey( operationName ) ) {
    return _operationCache.get( operationName );
  }

  Binding b = _port.getBinding();
  PortType pt = b.getPortType();
  Operation op = pt.getOperation( operationName, null, null );
  if ( op != null ) {
    try {
      WsdlOperation wop = new WsdlOperation( b, op, _wsdlTypes );
      // cache the operation
      _operationCache.put( operationName, wop );
      return wop;
    } catch ( KettleException kse ) {
      LogChannel.GENERAL.logError( "Could not retrieve WSDL Operator for operation name: " + operationName );
      throw new KettleStepException(
        "Could not retrieve WSDL Operator for operation name: " + operationName, kse );
    }
  }
  return null;
}
 
Example #16
Source File: WSDLDocCreator.java    From jolie with GNU Lesser General Public License v2.1 6 votes vote down vote up
private Operation addOWOperation2PT( Definition def, PortType pt, OneWayOperationDeclaration op ) {
	Operation wsdlOp = def.createOperation();

	wsdlOp.setName( op.id() );
	wsdlOp.setStyle( OperationType.ONE_WAY );
	wsdlOp.setUndefined( false );

	Input in = def.createInput();
	Message msg_req = addRequestMessage( localDef, op );
	msg_req.setUndefined( false );
	in.setMessage( msg_req );
	wsdlOp.setInput( in );
	wsdlOp.setUndefined( false );

	pt.addOperation( wsdlOp );

	return wsdlOp;
}
 
Example #17
Source File: WSDLToCorbaBinding.java    From cxf with Apache License 2.0 5 votes vote down vote up
private List<PortType> getPortTypeList() throws Exception {
    Map<QName, PortType> portTypes = CastUtils.cast(def.getAllPortTypes());
    List<PortType> intfs = null;

    if (portTypes == null) {
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(
            "No PortTypes defined in wsdl", LOG);
        throw new Exception(msg.toString());
    }
    PortType portType = null;
    intfs = new ArrayList<>();
    if (portTypes.size() == 1) {
        portType = portTypes.values().iterator().next();
        interfaceNames.add(portType.getQName().getLocalPart());
        intfs.add(portType);
    } else if (portTypes.size() > 1) {
        if (def.getAllBindings().size() > 0) {
            throwMultipleMultipleTypeException(CastUtils.cast(def.getAllBindings().keySet(),
                                                              QName.class));
        }
        for (PortType port : portTypes.values()) {
            interfaceNames.add(port.getQName().getLocalPart());
            intfs.add(port);
        }
    }
    return intfs;
}
 
Example #18
Source File: WSDLHelper.java    From cxf with Apache License 2.0 5 votes vote down vote up
public List<PortType> getPortTypes(Definition def) {
    List<PortType> portTypes = new ArrayList<>();
    Collection<PortType> ite = CastUtils.cast(def.getPortTypes().values());
    for (PortType portType : ite) {
        portTypes.add(portType);
    }
    return portTypes;
}
 
Example #19
Source File: WSDLToCorbaBinding.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void addBindingOperations(Definition definition, PortType portType, Binding binding)
    throws Exception {

    List<Operation> ops = CastUtils.cast(portType.getOperations());
    for (Operation op : ops) {
        try {
            BindingOperation bindingOperation = definition.createBindingOperation();
            addCorbaOperationExtElement(bindingOperation, op);
            bindingOperation.setName(op.getName());
            if (op.getInput() != null) {
                BindingInput bindingInput = definition.createBindingInput();
                bindingInput.setName(op.getInput().getName());
                bindingOperation.setBindingInput(bindingInput);
            }
            if (op.getOutput() != null) {
                BindingOutput bindingOutput = definition.createBindingOutput();
                bindingOutput.setName(op.getOutput().getName());
                bindingOperation.setBindingOutput(bindingOutput);
            }
            // add Faults
            if (op.getFaults() != null && op.getFaults().size() > 0) {
                Collection<Fault> faults = CastUtils.cast(op.getFaults().values());
                for (Fault fault : faults) {
                    BindingFault bindingFault = definition.createBindingFault();
                    bindingFault.setName(fault.getName());
                    bindingOperation.addBindingFault(bindingFault);
                }
            }
            bindingOperation.setOperation(op);
            binding.addBindingOperation(bindingOperation);
        } catch (Exception ex) {
            LOG.warning("Operation " + op.getName() + " not mapped to CORBA binding.");
        }
    }
}
 
Example #20
Source File: TestWSDLCorbaWriterImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void printPortTypes(@SuppressWarnings("rawtypes")java.util.Map portTypes,
                              Definition def, java.io.PrintWriter pw)
    throws WSDLException {
    Map<QName, PortType> map = new TreeMap<>(comparator);
    map.putAll(CastUtils.cast(portTypes, QName.class, PortType.class));
    super.printPortTypes(map, def, pw);
}
 
Example #21
Source File: JAXWSDefinitionBuilder.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void registerJaxwsExtension(ExtensionRegistry registry) {
    registerJAXWSBinding(registry, Definition.class);
    registerJAXWSBinding(registry, Service.class);
    registerJAXWSBinding(registry, Fault.class);
    registerJAXWSBinding(registry, PortType.class);
    registerJAXWSBinding(registry, Port.class);
    registerJAXWSBinding(registry, Operation.class);
    registerJAXWSBinding(registry, Binding.class);
    registerJAXWSBinding(registry, BindingOperation.class);
}
 
Example #22
Source File: WSDLToSoapProcessor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private boolean isPortTypeExisted() {
    portTypes = CastUtils.cast(wsdlDefinition.getPortTypes());
    if (portTypes == null) {
        return false;
    }
    for (Entry<QName, PortType> entry : portTypes.entrySet()) {
        String existPortName = entry.getKey().getLocalPart();
        if (existPortName.equals(env.get(ToolConstants.CFG_PORTTYPE))) {
            portType = entry.getValue();
            break;
        }
    }
    return (portType == null) ? false : true;
}
 
Example #23
Source File: WSDLToXMLProcessor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private boolean isPortTypeExisted() {
    portTypes = CastUtils.cast(wsdlDefinition.getPortTypes());
    if (portTypes == null) {
        return false;
    }
    for (Map.Entry<QName, PortType> entry : portTypes.entrySet()) {
        String existPortName = entry.getKey().getLocalPart();
        if (existPortName.equals(env.get(ToolConstants.CFG_PORTTYPE))) {
            portType = entry.getValue();
            break;
        }
    }
    return (portType == null) ? false : true;
}
 
Example #24
Source File: WSDLDefinitionBuilderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testBuildImportedWSDL() throws Exception {
    String wsdlUrl = getClass().getResource("hello_world_services.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());

    String serviceQName = "http://apache.org/hello_world/services";
    Service service = (Service)services.get(new QName(serviceQName, "SOAPService"));
    assertNotNull(service);

    Map<?, ?> ports = service.getPorts();
    assertNotNull(ports);
    assertEquals(1, ports.size());
    Port port = service.getPort("SoapPort");
    assertNotNull(port);

    Binding binding = port.getBinding();
    assertNotNull(binding);
    QName bindingQName = new QName("http://apache.org/hello_world/bindings", "SOAPBinding");
    assertEquals(bindingQName, binding.getQName());
    PortType portType = binding.getPortType();
    assertNotNull(portType);
    QName portTypeQName = new QName("http://apache.org/hello_world", "Greeter");
    assertEquals(portTypeQName, portType.getQName());
    Operation op1 = portType.getOperation("sayHi", "sayHiRequest", "sayHiResponse");
    assertNotNull(op1);
    QName messageQName = new QName("http://apache.org/hello_world/messages", "sayHiRequest");
    assertEquals(messageQName, op1.getInput().getMessage().getQName());

    Part part = op1.getInput().getMessage().getPart("in");
    assertNotNull(part);
    assertEquals(new QName("http://apache.org/hello_world/types", "sayHi"), part.getElementName());
}
 
Example #25
Source File: PortTypeVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private Binding findBinding(PortType intf) {
    Object[] bindings = rootDefinition.getBindings().values().toArray();
    for (int i = 0; i < bindings.length; i++) {
        Binding binding = (Binding) bindings[i];
        if (binding.getPortType().getQName().equals(intf.getQName())) {
            return binding;
        }
    }
    throw new RuntimeException("[InterfaceVisitor] Couldn't find binding for porttype "
                               + intf.getQName());
}
 
Example #26
Source File: ServiceWSDLBuilderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testPingMeOperation() throws Exception {
    setupWSDL(WSDL_PATH);
    PortType portType = newDef.getPortType(new QName(newDef.getTargetNamespace(),
        "Greeter"));
    Operation pingMe = portType.getOperation("pingMe", "pingMeRequest", "pingMeResponse");
    assertNotNull(pingMe);
    assertEquals("pingMe", pingMe.getName());
    Input input = pingMe.getInput();
    assertNotNull(input);
    assertEquals("pingMeRequest", input.getName());
    Message message = input.getMessage();
    assertNotNull(message);
    assertEquals("pingMeRequest", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("in", message.getPart("in").getName());
    Output output = pingMe.getOutput();
    assertNotNull(output);
    assertEquals("pingMeResponse", output.getName());
    message = output.getMessage();
    assertNotNull(message);
    assertEquals("pingMeResponse", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(message.getParts().size(), 1);
    assertEquals("out", message.getPart("out").getName());
    assertEquals(1, pingMe.getFaults().size());
    Fault fault = pingMe.getFault("pingMeFault");
    assertNotNull(fault);
    assertEquals("pingMeFault", fault.getName());
    message = fault.getMessage();
    assertNotNull(message);
    assertEquals("pingMeFault", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("faultDetail", message.getPart("faultDetail").getName());
    assertNull(message.getPart("faultDetail").getTypeName());
}
 
Example #27
Source File: ServiceWSDLBuilderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testGreetMeOperation() throws Exception {
    setupWSDL(WSDL_PATH);
    PortType portType = newDef.getPortType(new QName(newDef.getTargetNamespace(),
        "Greeter"));
    Operation greetMe = portType.getOperation("greetMe", "greetMeRequest", "greetMeResponse");
    assertNotNull(greetMe);
    assertEquals("greetMe", greetMe.getName());
    Input input = greetMe.getInput();
    assertNotNull(input);
    assertEquals("greetMeRequest", input.getName());
    Message message = input.getMessage();
    assertNotNull(message);
    assertEquals("greetMeRequest", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("in", message.getPart("in").getName());
    Output output = greetMe.getOutput();
    assertNotNull(output);
    assertEquals("greetMeResponse", output.getName());
    message = output.getMessage();
    assertNotNull(message);
    assertEquals("greetMeResponse", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("out", message.getPart("out").getName());
    assertEquals(0, greetMe.getFaults().size());

}
 
Example #28
Source File: ServiceWSDLBuilderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testSayHiOperation() throws Exception {
    setupWSDL(WSDL_PATH);
    PortType portType = newDef.getPortType(new QName(newDef.getTargetNamespace(),
        "Greeter"));
    Collection<Operation> operations =
        CastUtils.cast(
            portType.getOperations(), Operation.class);

    assertEquals(4, operations.size());
    Operation sayHi = portType.getOperation("sayHi", "sayHiRequest", "sayHiResponse");
    assertNotNull(sayHi);
    assertEquals(sayHi.getName(), "sayHi");
    Input input = sayHi.getInput();
    assertNotNull(input);
    assertEquals("sayHiRequest", input.getName());
    Message message = input.getMessage();
    assertNotNull(message);
    assertEquals("sayHiRequest", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("in", message.getPart("in").getName());
    Output output = sayHi.getOutput();
    assertNotNull(output);
    assertEquals("sayHiResponse", output.getName());
    message = output.getMessage();
    assertNotNull(message);
    assertEquals("sayHiResponse", message.getQName().getLocalPart());
    assertEquals(newDef.getTargetNamespace(), message.getQName().getNamespaceURI());
    assertEquals(1, message.getParts().size());
    assertEquals("out", message.getPart("out").getName());
    assertEquals(0, sayHi.getFaults().size());

}
 
Example #29
Source File: ServiceWSDLBuilderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testPortType() throws Exception {
    setupWSDL(WSDL_PATH);
    assertEquals(1, newDef.getPortTypes().size());
    PortType portType = (PortType)newDef.getPortTypes().values().iterator().next();
    assertNotNull(portType);
    assertEquals(portType.getQName(), new QName(newDef.getTargetNamespace(), "Greeter"));

}
 
Example #30
Source File: WSDLManagerImplTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testBuildImportedWSDL() throws Exception {
    String wsdlUrl = getClass().getResource("hello_world_services.wsdl").toString();

    WSDLManager builder = new WSDLManagerImpl();
    Definition def = builder.getDefinition(wsdlUrl);

    assertNotNull(def);
    Map<?, ?> services = def.getServices();
    assertNotNull(services);
    assertEquals(1, services.size());

    String serviceQName = "http://apache.org/hello_world/services";
    Service service = (Service)services.get(new QName(serviceQName, "SOAPService"));
    assertNotNull(service);

    Map<?, ?> ports = service.getPorts();
    assertNotNull(ports);
    assertEquals(1, ports.size());
    Port port = service.getPort("SoapPort");
    assertNotNull(port);

    Binding binding = port.getBinding();
    assertNotNull(binding);
    QName bindingQName = new QName("http://apache.org/hello_world/bindings", "SOAPBinding");
    assertEquals(bindingQName, binding.getQName());
    PortType portType = binding.getPortType();
    assertNotNull(portType);
    QName portTypeQName = new QName("http://apache.org/hello_world", "Greeter");
    assertEquals(portTypeQName, portType.getQName());
    Operation op1 = portType.getOperation("sayHi", "sayHiRequest", "sayHiResponse");
    assertNotNull(op1);
    QName messageQName = new QName("http://apache.org/hello_world/messages", "sayHiRequest");
    assertEquals(messageQName, op1.getInput().getMessage().getQName());

    Part part = op1.getInput().getMessage().getPart("in");
    assertNotNull(part);
    assertEquals(new QName("http://apache.org/hello_world/types", "sayHi"), part.getElementName());
}