Search in sources :

Example 6 with ParameterBinding

use of com.sun.xml.ws.api.model.ParameterBinding in project metro-jax-ws by eclipse-ee4j.

the class RuntimeModeler method processDocBareMethod.

/**
 * models a document/literal bare method
 * @param javaMethod the runtime model <code>JavaMethod</code> instance being created
 * @param operationName the runtime model <code>JavaMethod</code> instance being created
 * @param method the runtime model <code>JavaMethod</code> instance being created
 */
protected void processDocBareMethod(JavaMethodImpl javaMethod, String operationName, Method method) {
    String resultName = operationName + RESPONSE;
    String resultTNS = targetNamespace;
    String resultPartName = null;
    boolean isResultHeader = false;
    WebResult webResult = getAnnotation(method, WebResult.class);
    if (webResult != null) {
        if (webResult.name().length() > 0)
            resultName = webResult.name();
        if (webResult.targetNamespace().length() > 0)
            resultTNS = webResult.targetNamespace();
        resultPartName = webResult.partName();
        isResultHeader = webResult.header();
    }
    Class returnType = method.getReturnType();
    Type gReturnType = method.getGenericReturnType();
    if (javaMethod.isAsync()) {
        returnType = getAsyncReturnType(method, returnType);
    }
    if ((returnType != null) && (!returnType.getName().equals("void"))) {
        Annotation[] rann = getAnnotations(method);
        if (resultName != null) {
            QName responseQName = new QName(resultTNS, resultName);
            TypeInfo rTypeReference = new TypeInfo(responseQName, returnType, rann);
            rTypeReference.setGenericType(gReturnType);
            metadataReader.getProperties(rTypeReference.properties(), method);
            ParameterImpl returnParameter = new ParameterImpl(javaMethod, rTypeReference, Mode.OUT, -1);
            if (resultPartName == null || (resultPartName.length() == 0)) {
                resultPartName = resultName;
            }
            returnParameter.setPartName(resultPartName);
            if (isResultHeader) {
                returnParameter.setBinding(ParameterBinding.HEADER);
            } else {
                ParameterBinding rb = getBinding(operationName, resultPartName, false, Mode.OUT);
                returnParameter.setBinding(rb);
            }
            javaMethod.addParameter(returnParameter);
        }
    }
    // get WebParam
    Class<?>[] parameterTypes = method.getParameterTypes();
    Type[] genericParameterTypes = method.getGenericParameterTypes();
    Annotation[][] pannotations = getParamAnnotations(method);
    int pos = 0;
    for (Class clazzType : parameterTypes) {
        // method.getName();
        String paramName = operationName;
        String partName = null;
        String requestNamespace = targetNamespace;
        boolean isHeader = false;
        // async
        if (javaMethod.isAsync() && AsyncHandler.class.isAssignableFrom(clazzType)) {
            continue;
        }
        boolean isHolder = HOLDER_CLASS.isAssignableFrom(clazzType);
        // set the actual type argument of Holder in the TypeReference
        if (isHolder) {
            if (clazzType == Holder.class)
                clazzType = erasure(((ParameterizedType) genericParameterTypes[pos]).getActualTypeArguments()[0]);
        }
        Mode paramMode = isHolder ? Mode.INOUT : Mode.IN;
        for (Annotation annotation : pannotations[pos]) {
            if (annotation.annotationType() == jakarta.jws.WebParam.class) {
                jakarta.jws.WebParam webParam = (jakarta.jws.WebParam) annotation;
                paramMode = webParam.mode();
                if (isHolder && paramMode == Mode.IN)
                    paramMode = Mode.INOUT;
                isHeader = webParam.header();
                if (isHeader)
                    paramName = "arg" + pos;
                if (paramMode == Mode.OUT && !isHeader)
                    paramName = operationName + RESPONSE;
                if (webParam.name().length() > 0)
                    paramName = webParam.name();
                partName = webParam.partName();
                if (!webParam.targetNamespace().equals("")) {
                    requestNamespace = webParam.targetNamespace();
                }
                break;
            }
        }
        QName requestQName = new QName(requestNamespace, paramName);
        if (!isHeader && paramMode != Mode.OUT)
            javaMethod.setRequestPayloadName(requestQName);
        // doclit/wrapped
        // operationName with upper 1 char
        TypeInfo typeRef = new TypeInfo(requestQName, clazzType, pannotations[pos]);
        metadataReader.getProperties(typeRef.properties(), method, pos);
        typeRef.setGenericType(genericParameterTypes[pos]);
        ParameterImpl param = new ParameterImpl(javaMethod, typeRef, paramMode, pos++);
        if (partName == null || (partName.length() == 0)) {
            partName = paramName;
        }
        param.setPartName(partName);
        if (paramMode == Mode.INOUT) {
            ParameterBinding pb = getBinding(operationName, partName, isHeader, Mode.IN);
            param.setInBinding(pb);
            pb = getBinding(operationName, partName, isHeader, Mode.OUT);
            param.setOutBinding(pb);
        } else {
            if (isHeader) {
                param.setBinding(ParameterBinding.HEADER);
            } else {
                ParameterBinding pb = getBinding(operationName, partName, false, paramMode);
                param.setBinding(pb);
            }
        }
        javaMethod.addParameter(param);
    }
    validateDocBare(javaMethod);
    processExceptions(javaMethod, method);
}
Also used : QName(javax.xml.namespace.QName) Mode(jakarta.jws.WebParam.Mode) jakarta.jws(jakarta.jws) TypeInfo(com.sun.xml.ws.spi.db.TypeInfo) Annotation(java.lang.annotation.Annotation) ParameterBinding(com.sun.xml.ws.api.model.ParameterBinding) ParameterizedType(java.lang.reflect.ParameterizedType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) ExceptionType(com.sun.xml.ws.api.model.ExceptionType)

Example 7 with ParameterBinding

use of com.sun.xml.ws.api.model.ParameterBinding in project metro-jax-ws by eclipse-ee4j.

the class SOAPSEIModel method populateMaps.

@Override
protected void populateMaps() {
    int emptyBodyCount = 0;
    for (JavaMethodImpl jm : getJavaMethods()) {
        put(jm.getMethod(), jm);
        boolean bodyFound = false;
        for (ParameterImpl p : jm.getRequestParameters()) {
            ParameterBinding binding = p.getBinding();
            if (binding.isBody()) {
                put(p.getName(), jm);
                bodyFound = true;
            }
        }
        if (!bodyFound) {
            put(emptyBodyName, jm);
            // System.out.println("added empty body for: "+jm.getMethod().getName());
            emptyBodyCount++;
        }
    }
    if (emptyBodyCount > 1) {
    // TODO throw exception
    // System.out.println("Error: Unqiue signature violation - more than 1 empty body!");
    }
}
Also used : ParameterBinding(com.sun.xml.ws.api.model.ParameterBinding)

Example 8 with ParameterBinding

use of com.sun.xml.ws.api.model.ParameterBinding in project metro-jax-ws by eclipse-ee4j.

the class WSDLBoundOperationImpl method getResponsePayloadName.

@Override
@Nullable
public QName getResponsePayloadName() {
    if (emptyResponsePayload)
        return null;
    if (responsePayloadName != null)
        return responsePayloadName;
    if (style.equals(Style.RPC)) {
        String ns = getResponseNamespace() != null ? getResponseNamespace() : name.getNamespaceURI();
        responsePayloadName = new QName(ns, name.getLocalPart() + "Response");
        return responsePayloadName;
    } else {
        QName outMsgName = operation.getOutput().getMessage().getName();
        EditableWSDLMessage message = messages.get(outMsgName);
        for (EditableWSDLPart part : message.parts()) {
            ParameterBinding binding = getOutputBinding(part.getName());
            if (binding.isBody()) {
                responsePayloadName = part.getDescriptor().name();
                return responsePayloadName;
            }
        }
        // Its empty payload
        emptyResponsePayload = true;
    }
    // empty body
    return null;
}
Also used : EditableWSDLPart(com.sun.xml.ws.api.model.wsdl.editable.EditableWSDLPart) QName(javax.xml.namespace.QName) EditableWSDLMessage(com.sun.xml.ws.api.model.wsdl.editable.EditableWSDLMessage) ParameterBinding(com.sun.xml.ws.api.model.ParameterBinding) Nullable(com.sun.istack.Nullable)

Example 9 with ParameterBinding

use of com.sun.xml.ws.api.model.ParameterBinding in project metro-jax-ws by eclipse-ee4j.

the class RuntimeWSDLParser method parseMIMEPart.

private static void parseMIMEPart(XMLStreamReader reader, EditableWSDLBoundOperation op, BindingMode mode) {
    boolean bodyFound = false;
    Map<String, ParameterBinding> parts = null;
    if (mode == BindingMode.INPUT) {
        parts = op.getInputParts();
    } else if (mode == BindingMode.OUTPUT) {
        parts = op.getOutputParts();
    } else if (mode == BindingMode.FAULT) {
        parts = op.getFaultParts();
    }
    while (XMLStreamReaderUtil.nextElementContent(reader) != XMLStreamConstants.END_ELEMENT) {
        QName name = reader.getName();
        if (SOAPConstants.QNAME_BODY.equals(name) && !bodyFound) {
            bodyFound = true;
            parseSOAPBodyBinding(reader, op, mode);
            XMLStreamReaderUtil.next(reader);
        } else if (SOAPConstants.QNAME_HEADER.equals(name)) {
            bodyFound = true;
            parseSOAPHeaderBinding(reader, parts);
            XMLStreamReaderUtil.next(reader);
        } else if (MIMEConstants.QNAME_CONTENT.equals(name)) {
            String part = reader.getAttributeValue(null, "part");
            String type = reader.getAttributeValue(null, "type");
            if ((part == null) || (type == null)) {
                XMLStreamReaderUtil.skipElement(reader);
                continue;
            }
            ParameterBinding sb = ParameterBinding.createAttachment(type);
            if (parts != null && sb != null && part != null)
                parts.put(part, sb);
            XMLStreamReaderUtil.next(reader);
        } else {
            XMLStreamReaderUtil.skipElement(reader);
        }
    }
}
Also used : QName(javax.xml.namespace.QName) ParameterBinding(com.sun.xml.ws.api.model.ParameterBinding)

Aggregations

ParameterBinding (com.sun.xml.ws.api.model.ParameterBinding)9 QName (javax.xml.namespace.QName)8 EditableWSDLMessage (com.sun.xml.ws.api.model.wsdl.editable.EditableWSDLMessage)3 EditableWSDLPart (com.sun.xml.ws.api.model.wsdl.editable.EditableWSDLPart)3 Nullable (com.sun.istack.Nullable)2 ExceptionType (com.sun.xml.ws.api.model.ExceptionType)2 WSDLBoundOperation (com.sun.xml.ws.api.model.wsdl.WSDLBoundOperation)2 WSDLPart (com.sun.xml.ws.api.model.wsdl.WSDLPart)2 TypeInfo (com.sun.xml.ws.spi.db.TypeInfo)2 jakarta.jws (jakarta.jws)2 Mode (jakarta.jws.WebParam.Mode)2 Annotation (java.lang.annotation.Annotation)2 ParameterizedType (java.lang.reflect.ParameterizedType)2 Type (java.lang.reflect.Type)2 WSDLMessage (com.sun.xml.ws.api.model.wsdl.WSDLMessage)1 WSDLOperation (com.sun.xml.ws.api.model.wsdl.WSDLOperation)1 WSDLPortType (com.sun.xml.ws.api.model.wsdl.WSDLPortType)1 EditableWSDLBoundOperation (com.sun.xml.ws.api.model.wsdl.editable.EditableWSDLBoundOperation)1 EditableWSDLPortType (com.sun.xml.ws.api.model.wsdl.editable.EditableWSDLPortType)1 WrapperComposite (com.sun.xml.ws.spi.db.WrapperComposite)1