Java Code Examples for javax.wsdl.Part#getElementName()

The following examples show how to use javax.wsdl.Part#getElementName() . 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: WsdlOpParameterList.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Generate a WsdlOpParameter from the message part.
 *
 * @param part       A list of message part.
 * @param requesPart true if part from request message.
 */
private List<WsdlOpParameter> getParameter( Part part, boolean requesPart ) throws HopTransformException {

  List<WsdlOpParameter> params = new ArrayList<WsdlOpParameter>();

  if ( part.getElementName() != null ) {
    if ( WsdlUtils.isWrappedParameterStyle( _operation.getName(), !requesPart, part.getName() ) ) {
      _parameterStyle = WsdlOperation.SOAPParameterStyle.WRAPPED;
    }
    params.addAll( resolvePartElement( part ) );
  } else {
    params.add( new WsdlOpParameter( part.getName(), part.getTypeName(), _wsdlTypes.findNamedType( part
      .getTypeName() ), _wsdlTypes ) );
  }
  return params;
}
 
Example 2
Source File: WsdlOpParameterList.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Generate a WsdlOpParameter from the message part.
 *
 * @param part
 *          A list of message part.
 * @param requesPart
 *          true if part from request message.
 */
private List<WsdlOpParameter> getParameter( Part part, boolean requesPart ) throws KettleStepException {

  List<WsdlOpParameter> params = new ArrayList<WsdlOpParameter>();

  if ( part.getElementName() != null ) {
    if ( WsdlUtils.isWrappedParameterStyle( _operation.getName(), !requesPart, part.getName() ) ) {
      _parameterStyle = WsdlOperation.SOAPParameterStyle.WRAPPED;
    }
    params.addAll( resolvePartElement( part ) );
  } else {
    params.add( new WsdlOpParameter( part.getName(), part.getTypeName(), _wsdlTypes.findNamedType( part
      .getTypeName() ), _wsdlTypes ) );
  }
  return params;
}
 
Example 3
Source File: WsdlOpFaultList.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Create a WsdlOpFault from the Fault.
 *
 * @param fault
 *          Fault to process.
 * @return WsdlOpFault Result of processing.
 */
@SuppressWarnings( "unchecked" )
private WsdlOpFault getFault( Fault fault ) throws KettleStepException {
  Message m = fault.getMessage();

  // a fault should only have one message part.
  Map<?, Part> partMap = m.getParts();
  if ( partMap.size() != 1 ) {
    throw new IllegalArgumentException( "Invalid part count for fault!!" );
  }
  Part faultPart = partMap.values().iterator().next();
  boolean complexType = false;

  // type of fault is specified either in Part's type or element attribute.
  QName type = faultPart.getTypeName();
  if ( type == null ) {
    type = faultPart.getElementName();
    Element schemaElement = _wsdlTypes.findNamedElement( type );
    type = _wsdlTypes.getTypeQName( schemaElement.getAttribute( "type" ) );
    complexType = true;
  }
  return new WsdlOpFault( fault.getName(), type, complexType, _wsdlTypes );
}
 
Example 4
Source File: HeavyweightOperationInfoBuilder.java    From tomee with Apache License 2.0 6 votes vote down vote up
private XmlElementInfo getWrapperChild(Part part, String wsdlMessagePartName) throws OpenEJBException {
    // get the part name
    QName elementName = part.getElementName();
    wrapperElementQNames.add(elementName);

    // get the wrapper element
    XmlElementInfo wrapperElement = schemaInfo.elements.get(elementName);
    if (wrapperElement == null) {
        throw new OpenEJBException("No global element named " + elementName + " for operation " + operationName);
    }

    // get the wrapper type
    XmlTypeInfo wrapperType = schemaInfo.types.get(wrapperElement.xmlType);
    if (wrapperType == null) {
        throw new OpenEJBException("Can not find type " + wrapperElement.xmlType + " for element " + wrapperElement.qname + ", known types: " + schemaInfo.types.keySet());
    }

    // get the part type
    for (XmlElementInfo wrapperChild : wrapperType.elements.values()) {
        if (wrapperChild.qname.getLocalPart().equals(wsdlMessagePartName)) {
            return wrapperChild;
        }
    }
    throw new OpenEJBException("Global element named " + elementName + " does not define a child element named " + wsdlMessagePartName + " required by the operation " + operationName);
}
 
Example 5
Source File: WSDLToCorbaHelper.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected XmlSchemaType lookUpType(Part part) {
    XmlSchemaType schemaType = null;
    for (XmlSchema xmlSchema : xmlSchemaList.getXmlSchemas()) {
        if (part.getElementName() != null) {
            XmlSchemaElement schemaElement = xmlSchema.getElementByName(part.getElementName());
            if (schemaElement != null) {
                schemaType = schemaElement.getSchemaType();
            }
        } else {
            if (part.getTypeName() != null) {
                schemaType = xmlSchema.getTypeByName(part.getTypeName());
            }
        }
        if (schemaType != null) {
            return schemaType;
        }
    }

    return schemaType;
}
 
Example 6
Source File: UniqueBodyPartsValidator.java    From cxf with Apache License 2.0 6 votes vote down vote up
private boolean isUniqueBodyPart(String operationName, Message msg,
                                 Collection<String> headers, QName bindingName) {
    List<Part> partList = CastUtils.cast(msg.getOrderedParts(null));
    for (Part part : partList) {
        if (headers.contains(part.getName())) {
            continue;
        }
        if (part.getElementName() == null) {
            return true;
        }
        String opName = getOperationNameWithSamePart(operationName, part);
        if (opName != null) {
            addErrorMessage("Non unique body parts, operation " + "[ " + opName + " ] "
                            + "and operation [ " + operationName + " ] in binding "
                            + bindingName.toString()
                            + " have the same body block: "
                            + part.getElementName());
            return false;
        }
        //just need to check the first element
        return true;
    }
    return true;
}
 
Example 7
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 8
Source File: PublishMetadataRunnable.java    From tesb-studio-se with Apache License 2.0 6 votes vote down vote up
private static List<QName> getMessageParts(Message msg) {
    List<QName> result = new ArrayList<QName>();
    @SuppressWarnings("unchecked")
    Collection<Part> values = msg.getParts().values();
    if (values == null || values.isEmpty()) {
        return result;
    }
    Iterator<Part> iterator = values.iterator();
    while (iterator.hasNext()) {
        Part part = iterator.next();
        if (part.getElementName() != null) {
            result.add(part.getElementName());
        } else if (part.getTypeName() != null) {
            result.add(part.getTypeName());
        }
    }
    return result;
}
 
Example 9
Source File: WsdlOpFaultList.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Create a WsdlOpFault from the Fault.
 *
 * @param fault Fault to process.
 * @return WsdlOpFault Result of processing.
 */
@SuppressWarnings( "unchecked" )
private WsdlOpFault getFault( Fault fault ) throws HopTransformException {
  Message m = fault.getMessage();

  // a fault should only have one message part.
  Map<?, Part> partMap = m.getParts();
  if ( partMap.size() != 1 ) {
    throw new IllegalArgumentException( "Invalid part count for fault!!" );
  }
  Part faultPart = partMap.values().iterator().next();
  boolean complexType = false;

  // type of fault is specified either in Part's type or element attribute.
  QName type = faultPart.getTypeName();
  if ( type == null ) {
    type = faultPart.getElementName();
    Element schemaElement = _wsdlTypes.findNamedElement( type );
    type = _wsdlTypes.getTypeQName( schemaElement.getAttribute( "type" ) );
    complexType = true;
  }
  return new WsdlOpFault( fault.getName(), type, complexType, _wsdlTypes );
}
 
Example 10
Source File: WSIBPValidator.java    From cxf with Apache License 2.0 5 votes vote down vote up
private boolean isHeaderPart(final BindingOperation bop, final Part part) {
    QName elementName = part.getElementName();
    if (elementName != null) {
        String partName = elementName.getLocalPart();
        SoapHeader inSoapHeader = SOAPBindingUtil.getBindingInputSOAPHeader(bop);
        if (inSoapHeader != null) {
            return partName.equals(inSoapHeader.getPart());
        }
        SoapHeader outSoapHeader = SOAPBindingUtil.getBindingOutputSOAPHeader(bop);
        if (outSoapHeader != null) {
            return partName.equals(outSoapHeader.getPart());
        }
    }
    return false;
}
 
Example 11
Source File: WSIBPValidator.java    From cxf with Apache License 2.0 5 votes vote down vote up
public boolean checkR2205() {
    Collection<Binding> bindings = CastUtils.cast(def.getBindings().values());
    for (Binding binding : bindings) {

        if (!SOAPBindingUtil.isSOAPBinding(binding)) {
            System.err.println("WSIBP Validator found <"
                               + binding.getQName() + "> is NOT a SOAP binding");
            continue;
        }
        if (binding.getPortType() == null) {
            //will error later
            continue;
        }

        for (Iterator<?> ite2 = binding.getPortType().getOperations().iterator(); ite2.hasNext();) {
            Operation operation = (Operation)ite2.next();
            Collection<Fault> faults = CastUtils.cast(operation.getFaults().values());
            if (CollectionUtils.isEmpty(faults)) {
                continue;
            }

            for (Fault fault : faults) {
                Message message = fault.getMessage();
                Collection<Part> parts = CastUtils.cast(message.getParts().values());
                for (Part part : parts) {
                    if (part.getElementName() == null) {
                        addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2205") + "In Message "
                            + message.getQName() + ", part " + part.getName()
                                + " must specify a 'element' attribute");
                        return false;
                    }
                }
            }
        }
    }
    return true;
}
 
Example 12
Source File: UniqueBodyPartsValidator.java    From cxf with Apache License 2.0 5 votes vote down vote up
private String getOperationNameWithSamePart(String operationName, Part part) {
    QName partQN = part.getElementName();
    String opName = uniqueBodyPartsMap.get(partQN);
    if (opName == null) {
        uniqueBodyPartsMap.put(partQN, operationName);
        return null;
    }
    return opName;
}
 
Example 13
Source File: WSDLParameter.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static XmlSchemaElement getElement(Part part, SchemaCollection xmlSchemaList) throws Exception {
    XmlSchemaElement schemaElement = null;

    for (XmlSchema xmlSchema : xmlSchemaList.getXmlSchemas()) {
        if (part.getElementName() != null) {
            schemaElement = findElement(xmlSchema, part.getElementName());
            if (schemaElement != null) {
                return schemaElement;
            }
        }
    }
    return schemaElement;
}
 
Example 14
Source File: OperationInfo.java    From tesb-studio-se with Apache License 2.0 5 votes vote down vote up
private static ParameterInfo getParameterFromMessage(Message msg) {
    ParameterInfo parameterRoot = new ParameterInfo();
    List<Part> msgParts = msg.getOrderedParts(null);
    if (msgParts.size() > 1) {
        parameterRoot.setName(ParameterInfo.MULTIPART);
    } else if (msgParts.size() == 1) {
        Part part = msgParts.iterator().next();
        if (part.getElementName() != null) {
            parameterRoot.setName(part.getElementName());
        } else if (part.getTypeName() != null) {
            parameterRoot.setName(part.getTypeName());
        }
    }
    return parameterRoot;
}
 
Example 15
Source File: WSDL11SOAPOperationExtractor.java    From carbon-apimgt with Apache License 2.0 4 votes vote down vote up
/**
 * Gets swagger output parameter model for a given soap operation
 *
 * @param bindingOperation soap operation
 * @return list of swagger models for the parameters
 * @throws APIMgtWSDLException
 */
private List<ModelImpl> getSoapOutputParameterModel(BindingOperation bindingOperation) throws APIMgtWSDLException {
    List<ModelImpl> outputParameterModelList = new ArrayList<>();
    Operation operation = bindingOperation.getOperation();
    if (operation != null) {
        Output output = operation.getOutput();
        if (output != null) {
            Message message = output.getMessage();
            if (message != null) {
                Map map = message.getParts();

                for (Object obj : map.entrySet()) {
                    Map.Entry entry = (Map.Entry) obj;
                    Part part = (Part) entry.getValue();
                    if (part != null) {
                        if (part.getElementName() != null) {
                            outputParameterModelList.add(parameterModelMap.get(part.getElementName()
                                    .getLocalPart()));
                        } else {
                            if (part.getTypeName() != null && parameterModelMap
                                    .containsKey(part.getTypeName().getLocalPart())) {
                                outputParameterModelList
                                        .add(parameterModelMap.get(part.getTypeName().getLocalPart()));
                            } else {
                                ModelImpl model = new ModelImpl();
                                model.setType(ObjectProperty.TYPE);
                                model.setName(message.getQName().getLocalPart());
                                if (getPropertyFromDataType(part.getTypeName().getLocalPart()) instanceof RefProperty) {
                                    RefProperty property = (RefProperty) getPropertyFromDataType(part.getTypeName()
                                            .getLocalPart());
                                    property.set$ref(SOAPToRESTConstants.Swagger.DEFINITIONS_ROOT +
                                            part.getTypeName().getLocalPart());
                                    model.addProperty(part.getName(), property);
                                } else {
                                    model.addProperty(part.getName(),
                                            getPropertyFromDataType(part.getTypeName().getLocalPart()));
                                }
                                parameterModelMap.put(model.getName(), model);
                                outputParameterModelList.add(model);
                            }
                        }
                    }
                }
            }
        }
    }
    return outputParameterModelList;
}
 
Example 16
Source File: HeavyweightOperationInfoBuilder.java    From tomee with Apache License 2.0 4 votes vote down vote up
public JaxRpcOperationInfo buildOperationInfo() throws OpenEJBException {
    if (operationInfo != null) {
        return operationInfo;
    }

    operationInfo = new JaxRpcOperationInfo();
    operationInfo.name = operationName;

    // Binding style rpc/encoded, doc/lit, wrapped, etc.
    operationInfo.bindingStyle = bindingStyle;

    // Operation style one way, request response, etc/
    operationInfo.operationStyle = operationStyle;

    // Java method name
    operationInfo.javaMethodName = methodMapping.getJavaMethodName();

    //
    // Map the parameters
    //
    mapParameters();

    //
    // Map return
    //
    if (methodMapping.getWsdlReturnValueMapping() != null) {
        mapReturnType();
    }

    // Validate output mapping is complete
    if (outputMessage != null && bindingStyle.isWrapped()) {
        Part inputPart = getWrappedPart(outputMessage);

        QName wrapperName = inputPart.getElementName();
        XmlElementInfo wraperElement = schemaInfo.elements.get(wrapperName);
        XmlTypeInfo wrapperType = schemaInfo.types.get(wraperElement.xmlType);

        Set<String> expectedOutParams = new HashSet<>();
        for (XmlElementInfo expectedOutParam : wrapperType.elements.values()) {
            expectedOutParams.add(expectedOutParam.qname.getLocalPart());
        }
        if (!outParamNames.equals(expectedOutParams)) {
            throw new OpenEJBException("Not all wrapper children were mapped to parameters or a return value for operation " + operationName);
        }
    } else if (null != outputMessage) {
        if (!outParamNames.equals(outputMessage.getParts().keySet())) {
            throw new OpenEJBException("Not all output message parts were mapped to parameters or a return value for operation " + operationName);
        }
    }

    //
    // Map faults (exception)
    //
    for (Fault fault : faults) {
        JaxRpcFaultInfo faultInfo = mapFaults(fault);
        operationInfo.faults.add(faultInfo);
    }

    return operationInfo;
}
 
Example 17
Source File: HeavyweightOperationInfoBuilder.java    From tomee with Apache License 2.0 4 votes vote down vote up
private JaxRpcParameterInfo[] mapParameters() throws OpenEJBException {
    List<MethodParamPartsMapping> paramMappings = methodMapping.getMethodParamPartsMapping();

    //
    // Map the ParameterDesc instance in an array so they can be ordered properly
    // before they are added to the the OperationDesc.
    //
    JaxRpcParameterInfo[] parameterInfos = new JaxRpcParameterInfo[paramMappings.size()];
    for (MethodParamPartsMapping paramMapping : paramMappings) {
        JaxRpcParameterInfo parameterInfo = mapParameter(paramMapping);
        parameterInfos[paramMapping.getParamPosition().intValue()] = parameterInfo;
    }

    //
    // verify that all parameters were mapped and we don't have nulls in the parameter array
    //
    for (int i = 0; i < parameterInfos.length; i++) {
        if (parameterInfos[i] == null) {
            throw new OpenEJBException("There is no mapping for parameter number " + i + " for operation " + operationName);
        }
    }

    //
    // Verify that all parameter names were mapped
    //
    if (bindingStyle.isWrapped()) {
        // verify that all child elements have a parameter mapping
        Part inputPart = getWrappedPart(inputMessage);

        QName wrapperName = inputPart.getElementName();
        XmlElementInfo wrapperElement = schemaInfo.elements.get(wrapperName);
        XmlTypeInfo wrapperType = schemaInfo.types.get(wrapperElement.xmlType);

        Set<String> expectedInParams = new HashSet<>();
        for (XmlElementInfo expectedInParam : wrapperType.elements.values()) {
            expectedInParams.add(expectedInParam.qname.getLocalPart());
        }
        if (!inParamNames.equals(expectedInParams)) {
            throw new OpenEJBException("Not all wrapper children were mapped for operation name" + operationName);
        }
    } else {
        // verify all input message parts are mapped
        if (!inParamNames.equals(inputMessage.getParts().keySet())) {
            throw new OpenEJBException("Not all input message parts were mapped for operation name" + operationName);
        }
    }

    return parameterInfos;
}
 
Example 18
Source File: HeavyweightOperationInfoBuilder.java    From tomee with Apache License 2.0 4 votes vote down vote up
private QName getPartName(Part part) {
    return part.getElementName() == null ? part.getTypeName() : part.getElementName();
}