javax.wsdl.Operation Java Examples

The following examples show how to use javax.wsdl.Operation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WSDLDocCreator.java    From jolie with GNU Lesser General Public License v2.1 6 votes vote down vote up
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 #2
Source File: JaxWsServiceFactoryBean.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Override
protected void initializeWSDLOperation(InterfaceInfo intf, OperationInfo o, Method method) {
    method = ((JaxWsServiceConfiguration)jaxWsConfiguration).getDeclaredMethod(method);
    o.setProperty(Method.class.getName(), method);
    o.setProperty(METHOD, method);
    initializeWrapping(o, method);

    // rpc out-message-part-info class mapping
    Operation op = (Operation)o.getProperty(WSDLServiceBuilder.WSDL_OPERATION);

    initializeClassInfo(o, method, op == null ? null
        : CastUtils.cast(op.getParameterOrdering(), String.class));

    bindOperation(o, method);

    sendEvent(Event.INTERFACE_OPERATION_BOUND, o, method);
}
 
Example #3
Source File: ServiceWSDLBuilder.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void buildBindingOperation(Definition def, Binding binding,
                                   Collection<BindingOperationInfo> bindingOperationInfos) {
    BindingOperation bindingOperation = null;
    for (BindingOperationInfo bindingOperationInfo : bindingOperationInfos) {
        bindingOperation = def.createBindingOperation();
        addDocumentation(bindingOperation, bindingOperationInfo.getDocumentation());
        bindingOperation.setName(bindingOperationInfo.getName().getLocalPart());
        for (Operation operation
                : CastUtils.cast(binding.getPortType().getOperations(), Operation.class)) {
            if (operation.getName().equals(bindingOperation.getName())) {
                bindingOperation.setOperation(operation);
                break;
            }
        }
        buildBindingInput(def, bindingOperation, bindingOperationInfo.getInput());
        buildBindingOutput(def, bindingOperation, bindingOperationInfo.getOutput());
        buildBindingFault(def, bindingOperation, bindingOperationInfo.getFaults());
        addExtensibilityAttributes(def, bindingOperation, bindingOperationInfo.getExtensionAttributes());
        addExtensibilityElements(def, bindingOperation, getWSDL11Extensors(bindingOperationInfo));
        binding.addBindingOperation(bindingOperation);
    }
}
 
Example #4
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 #5
Source File: WSDL11SOAPOperationExtractor.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the target namespace given the soap binding operation
 *
 * @param bindingOperation soap operation
 * @return target name space
 */
private String getTargetNamespace(BindingOperation bindingOperation) {

    Operation operation = bindingOperation.getOperation();
    if (operation != null) {
        Input input = operation.getInput();

        if (input != null) {
            Message message = input.getMessage();
            if (message != null) {
                Map partMap = message.getParts();

                for (Object obj : partMap.entrySet()) {
                    Map.Entry entry = (Map.Entry) obj;
                    Part part = (Part) entry.getValue();
                    if (part != null) {
                        if (part.getElementName() != null) {
                            return part.getElementName().getNamespaceURI();
                        }
                    }
                }
            }
        }
    }
    return targetNamespace;
}
 
Example #6
Source File: OperationInfo.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
public OperationInfo(Operation operation) {
    targetMethodName = operation.getName();

    Input inDef = operation.getInput();
    if (inDef != null) {
        Message inMsg = inDef.getMessage();
        if (inMsg != null) {
            input = getParameterFromMessage(inMsg);
        }
    }
    Output outDef = operation.getOutput();
    if (outDef != null) {
        Message outMsg = outDef.getMessage();
        if (outMsg != null) {
            output = getParameterFromMessage(outMsg);
        }
    }
    for (Fault fault : (Collection<Fault>) operation.getFaults().values()) {
        Message faultMsg = fault.getMessage();
        if (faultMsg != null) {
            faults.add(getParameterFromMessage(faultMsg));
        }
    }
}
 
Example #7
Source File: PublishMetadataRunnable.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
private static void addParamsToPath(final QName portType, Operation oper, Message msg, final Set<String> paths,
        final Set<QName> alreadyCreated) throws URISyntaxException {
    if (msg != null) {
        List<QName> messageParts = getMessageParts(msg);
        if (messageParts.isEmpty()) {
            return;
        }
        for(QName messagePart : messageParts) {
            if (alreadyCreated.add(messagePart)) {
                String folderPath = FolderNameUtil.getImportedXmlSchemaPath(messagePart.getNamespaceURI(),
                        portType.getLocalPart(), oper.getName());
                paths.add(folderPath);
            }
        }
    }
}
 
Example #8
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 #9
Source File: WSDLToXMLProcessor.java    From cxf with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void addBindingOperation() throws ToolException {
    List<Operation> ops = portType.getOperations();
    for (Operation op : ops) {
        BindingOperation bindingOperation = wsdlDefinition.createBindingOperation();
        bindingOperation.setName(op.getName());
        if (op.getInput() != null) {
            bindingOperation.setBindingInput(getBindingInput(op.getInput(), op.getName()));
        }
        if (op.getOutput() != null) {
            bindingOperation.setBindingOutput(getBindingOutput(op.getOutput(), op.getName()));
        }
        if (op.getFaults() != null && op.getFaults().size() > 0) {
            addXMLFaults(op, bindingOperation);
        }
        bindingOperation.setOperation(op);
        binding.addBindingOperation(bindingOperation);
    }
}
 
Example #10
Source File: WSDLParameter.java    From cxf with Apache License 2.0 6 votes vote down vote up
public void processParameters(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation, Definition def,
                              SchemaCollection xmlSchemaList, List<ParamType> params,
                              List<ArgType> returns, boolean simpleOrdering) throws Exception {

    definition = def;
    List<ParamType> inputs = new ArrayList<>();
    List<ParamType> outputs = new ArrayList<>();
    List<ArgType> returnOutputs = new ArrayList<>();
    boolean isWrapped = isWrappedOperation(operation, xmlSchemaList);

    if (isWrapped) {
        processWrappedInputParams(wsdlToCorbaBinding, operation, xmlSchemaList, inputs);
    } else {
        processInputParams(wsdlToCorbaBinding, operation, xmlSchemaList, inputs);
    }
    if (isWrapped) {
        processWrappedOutputParams(wsdlToCorbaBinding, operation, xmlSchemaList, inputs, outputs);
    } else {
        processOutputParams(wsdlToCorbaBinding, operation, xmlSchemaList, inputs, outputs);
    }
    processReturnParams(outputs, returnOutputs);
    orderParameters(inputs, outputs, true);
    returns.addAll(returnOutputs);
    params.addAll(inputs);

}
 
Example #11
Source File: AttributeVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private Operation generateOperation(String name, Message inputMsg, Message outputMsg) {
    Input input = definition.createInput();
    input.setName(inputMsg.getQName().getLocalPart());
    input.setMessage(inputMsg);

    Output output = definition.createOutput();
    output.setName(outputMsg.getQName().getLocalPart());
    output.setMessage(outputMsg);

    Operation result = definition.createOperation();
    result.setName(name);
    result.setInput(input);
    result.setOutput(output);
    result.setUndefined(false);

    portType.addOperation(result);

    return result;
}
 
Example #12
Source File: AttributeVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
/** Generates a corba:operation in the corba:binding container within a wsdl:binding.
 *
 * Only one (or none) corba parameter and only one (or none) corba return parameter are supported.
 *
 * @param op is the wsdl operation to bind.
 * @param param is the corba parameter, none if null.
 * @param arg is the corba return parameter, none if null.
 * @return the generated corba:operation.
 */
private OperationType generateCorbaOperation(Operation op, ParamType param, ArgType arg) {
    OperationType operation = null;
    try {
        operation = (OperationType)extReg.createExtension(BindingOperation.class,
                                                          CorbaConstants.NE_CORBA_OPERATION);
    } catch (WSDLException ex) {
        throw new RuntimeException(ex);
    }
    operation.setName(op.getName());

    if (param != null) {
        operation.getParam().add(param);
    }

    if (arg != null) {
        operation.setReturn(arg);
    }

    return operation;
}
 
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: AttributeVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private BindingOperation generateCorbaBindingOperation(Binding wsdlBinding,
                                                       Operation op,
                                                       OperationType corbaOp) {
    BindingInput bindingInput = definition.createBindingInput();
    bindingInput.setName(op.getInput().getName());

    BindingOutput bindingOutput = definition.createBindingOutput();
    bindingOutput.setName(op.getOutput().getName());

    BindingOperation bindingOperation = definition.createBindingOperation();
    bindingOperation.addExtensibilityElement((ExtensibilityElement)corbaOp);
    bindingOperation.setOperation(op);
    bindingOperation.setName(op.getName());

    bindingOperation.setBindingInput(bindingInput);
    bindingOperation.setBindingOutput(bindingOutput);

    binding.addBindingOperation(bindingOperation);

    return bindingOperation;
}
 
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: 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 #17
Source File: OperationVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private BindingOperation generateBindingOperation(Binding wsdlBinding, Operation op,
                                                  String corbaOpName) {
    BindingOperation bindingOperation = definition.createBindingOperation();
    //OperationType operationType = null;
    try {
        corbaOperation = (OperationType)extReg.createExtension(BindingOperation.class,
                                                               CorbaConstants.NE_CORBA_OPERATION);
    } catch (WSDLException ex) {
        throw new RuntimeException(ex);
    }
    corbaOperation.setName(corbaOpName);
    bindingOperation.addExtensibilityElement((ExtensibilityElement)corbaOperation);
    bindingOperation.setOperation(op);
    bindingOperation.setName(op.getName());
    binding.addBindingOperation(bindingOperation);
    return bindingOperation;
}
 
Example #18
Source File: WSDLToSoapProcessor.java    From cxf with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void addBindingOperation() throws ToolException {
    /**
     * This method won't do unique operation name checking on portType The
     * WS-I Basic Profile[17] R2304 requires that operations within a
     * wsdl:portType have unique values for their name attribute so mapping
     * of WS-I compliant WSDLdescriptions will not generate Java interfaces
     * with overloaded methods. However, for backwards compatibility, JAX-WS
     * supports operation name overloading provided the overloading does not
     * cause conflicts (as specified in the Java Language Specification[25])
     * in the mapped Java service endpoint interface declaration.
     */
    List<Operation> ops = portType.getOperations();
    for (Operation op : ops) {
        BindingOperation bindingOperation = wsdlDefinition.createBindingOperation();
        setSoapOperationExtElement(bindingOperation);
        bindingOperation.setName(op.getName());
        if (op.getInput() != null) {
            bindingOperation.setBindingInput(getBindingInput(op.getInput()));
        }
        if (op.getOutput() != null) {
            bindingOperation.setBindingOutput(getBindingOutput(op.getOutput()));
        }
        if (op.getFaults() != null && op.getFaults().size() > 0) {
            addSoapFaults(op, bindingOperation);
        }
        bindingOperation.setOperation(op);
        binding.addBindingOperation(bindingOperation);
    }
}
 
Example #19
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 #20
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 #21
Source File: LightweightOperationInfoBuilder.java    From tomee with Apache License 2.0 5 votes vote down vote up
public LightweightOperationInfoBuilder(BindingOperation bindingOperation, Method method) throws OpenEJBException {
    if (bindingOperation == null) {
        throw new OpenEJBException("No BindingOperation supplied for method " + method.getName());
    }

    Operation operation = bindingOperation.getOperation();
    this.operationName = operation.getName();
    this.inputMessage = operation.getInput().getMessage();
    this.outputMessage = operation.getOutput() == null ? null : operation.getOutput().getMessage();
    this.method = method;
}
 
Example #22
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 #23
Source File: WsdlOperation.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new wsdl operation instance for the specified binding and operation.
 *
 * @param binding
 *          Binding for the operation.
 * @param op
 *          The operation.
 * @param wsdlTypes
 *          WSDL type information.
 */
protected WsdlOperation( Binding binding, Operation op, WsdlTypes wsdlTypes ) throws KettleException {

  _operationQName = new QName( wsdlTypes.getTargetNamespace(), op.getName() );
  _oneway = true;

  String soapBindingStyle = WsdlUtils.getSOAPBindingStyle( binding );
  if ( "rpc".equals( soapBindingStyle ) ) {
    _bindingStyle = SOAPBindingStyle.RPC;
  } else {
    _bindingStyle = SOAPBindingStyle.DOCUMENT;
  }

  String soapBindingUse = WsdlUtils.getSOAPBindingUse( binding, op.getName() );
  if ( "encoded".equals( soapBindingUse ) ) {
    _bindingUse = SOAPBindingUse.ENCODED;
  } else {
    _bindingUse = SOAPBindingUse.LITERAL;
  }

  _soapAction = WsdlUtils.getSOAPAction( binding.getBindingOperation( op.getName(), null, null ) );

  _params = new WsdlOpParameterList( op, binding, wsdlTypes );
  loadParameters( op );

  _faults = new WsdlOpFaultList( wsdlTypes );
  loadFaults( op );

  _returnType = _params.getReturnType();
  _parameterStyle = _params.getParameterStyle();
}
 
Example #24
Source File: WSDLToSoapProcessor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void addSoapFaults(Operation op, BindingOperation bindingOperation) throws ToolException {
    Map<String, Fault> faults = CastUtils.cast(op.getFaults());
    for (Fault fault : faults.values()) {
        BindingFault bf = wsdlDefinition.createBindingFault();
        bf.setName(fault.getName());
        setSoapFaultExtElement(bf);
        bindingOperation.addBindingFault(bf);
    }
}
 
Example #25
Source File: OperationVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public Message generateOutputMessage(Operation operation, BindingOperation bindingOperation) {
    Message msg = definition.createMessage();
    QName msgName;
    if (!mapper.isDefaultMapping()) {
        //mangle the message name
        //REVISIT, do we put in the entire scope for mangling
        msgName = new QName(definition.getTargetNamespace(),
                            getScope().tail() + "." + operation.getName() + RESPONSE_SUFFIX);
    } else {
        msgName = new QName(definition.getTargetNamespace(),
                            operation.getName() + RESPONSE_SUFFIX);
    }
    msg.setQName(msgName);
    msg.setUndefined(false);

    String outputName = operation.getName() + RESPONSE_SUFFIX;
    Output output = definition.createOutput();
    output.setName(outputName);
    output.setMessage(msg);

    BindingOutput bindingOutput = definition.createBindingOutput();
    bindingOutput.setName(outputName);

    bindingOperation.setBindingOutput(bindingOutput);
    operation.setOutput(output);

    definition.addMessage(msg);

    return msg;
}
 
Example #26
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 #27
Source File: WSDLToCorbaBinding.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void addCorbaOperationExtElement(BindingOperation bo, Operation op)
    throws Exception {

    OperationType operationType = null;
    try {
        operationType = (OperationType)extReg.createExtension(BindingOperation.class,
                                                              CorbaConstants.NE_CORBA_OPERATION);
    } catch (WSDLException wse) {
        LOG.log(Level.SEVERE, "Failed to create a Binding Operation extension", wse);
        throw new Exception(LOG.toString(), wse);
    }

    operationType.setName(op.getName());
    List<ParamType> params = new ArrayList<>();
    List<ArgType> returns = new ArrayList<>();

    wsdlParameter.processParameters(this, op, def, xmlSchemaList, params, returns, true);

    for (ParamType paramtype : params) {
        operationType.getParam().add(paramtype);
    }
    for (ArgType retType : returns) {
        operationType.setReturn(retType);
    }

    Collection<Fault> faults = CastUtils.cast(op.getFaults().values());
    for (Fault fault : faults) {
        RaisesType raisestype = new RaisesType();
        CorbaType extype = convertFaultToCorbaType(xmlSchemaType, fault);
        if (extype != null) {
            raisestype.setException(helper.createQNameCorbaNamespace(extype.getName()));
            operationType.getRaises().add(raisestype);
        }
    }

    bo.addExtensibilityElement((ExtensibilityElement)operationType);
}
 
Example #28
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 #29
Source File: OperationVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void createFaultMessage(CorbaTypeImpl corbaType,
                                Operation operation,
                                BindingOperation bindingOperation,
                                QName elementQName) {
    String exceptionName = corbaType.getQName().getLocalPart();

    Definition faultDef = manager.getWSDLDefinition(elementQName.getNamespaceURI());
    if (faultDef == null) {
        faultDef = definition;
    }
    Message faultMsg = faultDef.getMessage(new QName(faultDef.getTargetNamespace(), exceptionName));
    if (faultMsg == null) {
        throw new RuntimeException("Fault message for exception " + exceptionName + " not found");
    }

    // porttype - operation - fault
    Fault fault = definition.createFault();
    fault.setMessage(faultMsg);
    fault.setName(faultMsg.getQName().getLocalPart());
    operation.addFault(fault);

    // binding - operation - corba:operation - corba:raises
    RaisesType raisesType = new RaisesType();
    raisesType.setException(new QName(typeMap.getTargetNamespace(),
                                      exceptionName));
    corbaOperation.getRaises().add(raisesType);

    // binding - operation - fault
    BindingFault bindingFault = definition.createBindingFault();
    bindingFault.setName(faultMsg.getQName().getLocalPart());
    bindingOperation.addBindingFault(bindingFault);

    //add the fault element namespace to the definition
    String nsURI = elementQName.getNamespaceURI();
    manager.addWSDLDefinitionNamespace(definition, mapper.mapNSToPrefix(nsURI), nsURI);
}
 
Example #30
Source File: OperationVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public Message generateInputMessage(Operation operation, BindingOperation bindingOperation) {
    Message msg = definition.createMessage();
    QName msgName;
    if (!mapper.isDefaultMapping()) {
        //mangle the message name
        //REVISIT, do we put in the entire scope for mangling
        msgName = new QName(definition.getTargetNamespace(),
                            getScope().tail() + "." + operation.getName());
    } else {
        msgName = new QName(definition.getTargetNamespace(), operation.getName());
    }
    msg.setQName(msgName);
    msg.setUndefined(false);

    String inputName = operation.getName() + REQUEST_SUFFIX;
    Input input = definition.createInput();
    input.setName(inputName);
    input.setMessage(msg);

    BindingInput bindingInput = definition.createBindingInput();
    bindingInput.setName(inputName);

    bindingOperation.setBindingInput(bindingInput);
    operation.setInput(input);

    definition.addMessage(msg);

    return msg;
}