Search in sources :

Example 11 with BindingOperation

use of javax.wsdl.BindingOperation in project cxf by apache.

the class WSDLHelper method getBindingOperation.

public BindingOperation getBindingOperation(Definition def, String operationName) {
    if (operationName == null) {
        return null;
    }
    Iterator<Binding> ite = CastUtils.cast(def.getBindings().values().iterator());
    while (ite.hasNext()) {
        Binding binding = ite.next();
        Iterator<BindingOperation> ite1 = CastUtils.cast(binding.getBindingOperations().iterator());
        while (ite1.hasNext()) {
            BindingOperation bop = ite1.next();
            if (bop.getName().equals(operationName)) {
                return bop;
            }
        }
    }
    return null;
}
Also used : Binding(javax.wsdl.Binding) BindingOperation(javax.wsdl.BindingOperation)

Example 12 with BindingOperation

use of javax.wsdl.BindingOperation in project carbon-apimgt by wso2.

the class WSDL11ProcessorImpl method getHttpBindingOperations.

/**
 * Retrieves all the operations defined in the provided Binding.
 *
 * @param binding WSDL binding
 * @return a set of {@link WSDLOperation} defined in the provided Binding
 */
private Set<WSDLOperation> getHttpBindingOperations(Binding binding) {
    Set<WSDLOperation> allBindingOperations = new HashSet<>();
    if (binding.getExtensibilityElements() != null && binding.getExtensibilityElements().size() > 0) {
        if (binding.getExtensibilityElements().get(0) instanceof HTTPBinding) {
            HTTPBinding httpBinding = (HTTPBinding) binding.getExtensibilityElements().get(0);
            String verb = httpBinding.getVerb();
            for (Object opObj : binding.getBindingOperations()) {
                if (opObj instanceof BindingOperation) {
                    BindingOperation bindingOperation = (BindingOperation) opObj;
                    WSDLOperation wsdlOperation = getOperation(bindingOperation, verb);
                    if (wsdlOperation != null) {
                        allBindingOperations.add(wsdlOperation);
                    }
                }
            }
        }
    }
    return allBindingOperations;
}
Also used : BindingOperation(javax.wsdl.BindingOperation) WSDLOperation(org.wso2.carbon.apimgt.core.models.WSDLOperation) HTTPBinding(javax.wsdl.extensions.http.HTTPBinding) HashSet(java.util.HashSet)

Example 13 with BindingOperation

use of javax.wsdl.BindingOperation in project carbon-apimgt by wso2.

the class WSDL11ProcessorImpl method getParameters.

/**
 * Returns parameters, given http binding operation, verb and content type
 *
 * @param bindingOperation {@link BindingOperation} object
 * @param verb             HTTP verb
 * @param contentType      Content type
 * @return parameters, given http binding operation, verb and content type
 */
private List<WSDLOperationParam> getParameters(BindingOperation bindingOperation, String verb, String contentType) {
    List<WSDLOperationParam> params = new ArrayList<>();
    Operation operation = bindingOperation.getOperation();
    // or content type is not provided
    if (APIMWSDLUtils.canContainBody(verb) && !APIMWSDLUtils.hasFormDataParams(contentType)) {
        WSDLOperationParam param = new WSDLOperationParam();
        param.setName("Payload");
        param.setParamType(WSDLOperationParam.ParamTypeEnum.BODY);
        params.add(param);
        if (log.isDebugEnabled()) {
            log.debug("Adding default Param for operation:" + operation.getName() + ", contentType: " + contentType);
        }
        return params;
    }
    if (operation != null) {
        Input input = operation.getInput();
        if (input != null) {
            Message message = input.getMessage();
            if (message != null) {
                Map map = message.getParts();
                map.forEach((name, partObj) -> {
                    WSDLOperationParam param = new WSDLOperationParam();
                    param.setName(name.toString());
                    if (log.isDebugEnabled()) {
                        log.debug("Identified param for operation: " + operation.getName() + " param: " + name);
                    }
                    if (APIMWSDLUtils.canContainBody(verb)) {
                        if (log.isDebugEnabled()) {
                            log.debug("Operation " + operation.getName() + " can contain a body.");
                        }
                        // In POST, PUT operations, parameters always in body according to HTTP Binding spec
                        if (APIMWSDLUtils.hasFormDataParams(contentType)) {
                            param.setParamType(WSDLOperationParam.ParamTypeEnum.FORM_DATA);
                            if (log.isDebugEnabled()) {
                                log.debug("Param " + name + " type was set to formData.");
                            }
                        }
                    // no else block since if content type is not form-data related, there can be only one
                    // parameter which is payload body. This is handled in the first if block which is
                    // if (canContainBody(verb) && !hasFormDataParams(contentType)) { .. }
                    } else {
                        // In GET operations, parameters always query or path as per HTTP Binding spec
                        if (isUrlReplacement(bindingOperation)) {
                            param.setParamType(WSDLOperationParam.ParamTypeEnum.PATH);
                            if (log.isDebugEnabled()) {
                                log.debug("Param " + name + " type was set to Path.");
                            }
                        } else {
                            param.setParamType(WSDLOperationParam.ParamTypeEnum.QUERY);
                            if (log.isDebugEnabled()) {
                                log.debug("Param " + name + " type was set to Query.");
                            }
                        }
                    }
                    Part part = (Part) partObj;
                    param.setDataType(part.getTypeName().getLocalPart());
                    if (log.isDebugEnabled()) {
                        log.debug("Param " + name + " data type was set to " + param.getDataType());
                    }
                    params.add(param);
                });
            }
        }
    }
    return params;
}
Also used : WSDLOperationParam(org.wso2.carbon.apimgt.core.models.WSDLOperationParam) Input(javax.wsdl.Input) BindingInput(javax.wsdl.BindingInput) Message(javax.wsdl.Message) Part(javax.wsdl.Part) ArrayList(java.util.ArrayList) Operation(javax.wsdl.Operation) HTTPOperation(javax.wsdl.extensions.http.HTTPOperation) BindingOperation(javax.wsdl.BindingOperation) WSDLOperation(org.wso2.carbon.apimgt.core.models.WSDLOperation) Map(java.util.Map) HashMap(java.util.HashMap)

Example 14 with BindingOperation

use of javax.wsdl.BindingOperation in project tomee by apache.

the class JaxRpcServiceInfoBuilder method buildOperations.

private Set<QName> buildOperations(Binding binding, Class serviceEndpointInterface, boolean lightweight) throws OpenEJBException {
    Set<QName> wrappedElementQNames = new HashSet<QName>();
    for (Object op : binding.getBindingOperations()) {
        BindingOperation bindingOperation = (BindingOperation) op;
        String operationName = bindingOperation.getOperation().getName();
        if (lightweight) {
            // Lightweight mappings are solely based on the Java method
            Method method = getMethodForOperation(operationName, serviceEndpointInterface);
            // Build the operation info using the method
            LightweightOperationInfoBuilder operationInfoBuilder = new LightweightOperationInfoBuilder(bindingOperation, method);
            JaxRpcOperationInfo operationInfo = operationInfoBuilder.buildOperationInfo();
            serviceInfo.operations.add(operationInfo);
        } else {
            // Heavyweight mappings are solely based on the Java to XML mapping declarations
            ServiceEndpointMethodMapping methodMapping = getMethodMappingForOperation(operationName, serviceEndpointInterface);
            // Build the operation info using the Java to XML method mapping
            HeavyweightOperationInfoBuilder operationInfoBuilder = new HeavyweightOperationInfoBuilder(bindingOperation, methodMapping, javaWsdlMapping, schemaInfo);
            JaxRpcOperationInfo operationInfo = operationInfoBuilder.buildOperationInfo();
            serviceInfo.operations.add(operationInfo);
            // remember wrapped elements for type mapping
            Set<QName> wrappedElementQNamesForOper = operationInfoBuilder.getWrapperElementQNames();
            wrappedElementQNames.addAll(wrappedElementQNamesForOper);
        }
    }
    return wrappedElementQNames;
}
Also used : BindingOperation(javax.wsdl.BindingOperation) QName(javax.xml.namespace.QName) ServiceEndpointMethodMapping(org.apache.openejb.jee.ServiceEndpointMethodMapping) Method(java.lang.reflect.Method) HashSet(java.util.HashSet)

Example 15 with BindingOperation

use of javax.wsdl.BindingOperation in project cxf by apache.

the class JAXWSDefinitionBuilderTest method testBuildDefinitionWithXMLBinding.

@Test
public void testBuildDefinitionWithXMLBinding() {
    String qname = "http://apache.org/hello_world_xml_http/bare";
    String wsdlUrl = getClass().getResource("resources/hello_world_xml_bare.wsdl").toString();
    JAXWSDefinitionBuilder builder = new JAXWSDefinitionBuilder();
    builder.setBus(BusFactory.getDefaultBus());
    builder.setContext(env);
    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, "XMLService"));
    assertNotNull(service);
    Map<?, ?> ports = service.getPorts();
    assertNotNull(ports);
    assertEquals(1, ports.size());
    Port port = service.getPort("XMLPort");
    assertNotNull(port);
    assertEquals(1, port.getExtensibilityElements().size());
    Object obj = port.getExtensibilityElements().get(0);
    if (obj instanceof JAXBExtensibilityElement) {
        obj = ((JAXBExtensibilityElement) obj).getValue();
    }
    assertTrue(obj.getClass().getName() + " is not an AddressType", obj instanceof AddressType);
    Binding binding = port.getBinding();
    assertNotNull(binding);
    assertEquals(new QName(qname, "Greeter_XMLBinding"), binding.getQName());
    BindingOperation operation = binding.getBindingOperation("sayHi", null, null);
    assertNotNull(operation);
    BindingInput input = operation.getBindingInput();
    assertNotNull(input);
    assertEquals(1, input.getExtensibilityElements().size());
    obj = input.getExtensibilityElements().get(0);
    if (obj instanceof JAXBExtensibilityElement) {
        obj = ((JAXBExtensibilityElement) obj).getValue();
    }
    assertTrue(obj.getClass().getName() + " is not an XMLBindingMessageFormat", obj instanceof XMLBindingMessageFormat);
}
Also used : Binding(javax.wsdl.Binding) JAXBExtensibilityElement(org.apache.cxf.wsdl.JAXBExtensibilityElement) QName(javax.xml.namespace.QName) Port(javax.wsdl.Port) Definition(javax.wsdl.Definition) Service(javax.wsdl.Service) BindingInput(javax.wsdl.BindingInput) BindingOperation(javax.wsdl.BindingOperation) XMLBindingMessageFormat(org.apache.cxf.bindings.xformat.XMLBindingMessageFormat) AddressType(org.apache.cxf.wsdl.http.AddressType) JAXWSDefinitionBuilder(org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder) Test(org.junit.Test)

Aggregations

BindingOperation (javax.wsdl.BindingOperation)54 Binding (javax.wsdl.Binding)25 QName (javax.xml.namespace.QName)20 Operation (javax.wsdl.Operation)16 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)13 BindingInput (javax.wsdl.BindingInput)12 Test (org.junit.Test)12 File (java.io.File)9 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)9 OperationType (org.apache.cxf.binding.corba.wsdl.OperationType)9 Definition (javax.wsdl.Definition)8 Message (javax.wsdl.Message)8 BindingFault (javax.wsdl.BindingFault)7 Port (javax.wsdl.Port)7 Service (javax.wsdl.Service)7 SoapOperation (org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation)7 ToolException (org.apache.cxf.tools.common.ToolException)7 Input (javax.wsdl.Input)6 SOAPOperation (javax.wsdl.extensions.soap.SOAPOperation)6 SOAP12Binding (javax.wsdl.extensions.soap12.SOAP12Binding)6