Search in sources :

Example 1 with SOAPBindingImpl

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

the class RuntimeModeler method createBinding.

/**
 * creates a runtime model <code>SOAPBinding</code> from a <code>jakarta.jws.soap.SOAPBinding</code> object
 * @param soapBinding the <code>jakarta.jws.soap.SOAPBinding</code> to model
 * @return returns the runtime model SOAPBinding corresponding to <code>soapBinding</code>
 */
protected SOAPBindingImpl createBinding(SOAPBinding soapBinding) {
    SOAPBindingImpl rtSOAPBinding = new SOAPBindingImpl();
    Style style = soapBinding != null ? soapBinding.style() : Style.DOCUMENT;
    rtSOAPBinding.setStyle(style);
    assert bindingId != null;
    model.bindingId = bindingId;
    SOAPVersion soapVersion = bindingId.getSOAPVersion();
    rtSOAPBinding.setSOAPVersion(soapVersion);
    return rtSOAPBinding;
}
Also used : SOAPVersion(com.sun.xml.ws.api.SOAPVersion) Style(jakarta.jws.soap.SOAPBinding.Style) SOAPBindingImpl(com.sun.xml.ws.model.soap.SOAPBindingImpl)

Example 2 with SOAPBindingImpl

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

the class RuntimeModeler method processMethod.

/**
 * creates the runtime model for a method on the <code>portClass</code>
 * @param method the method to model
 */
private void processMethod(Method method) {
    // int mods = method.getModifiers();
    WebMethod webMethod = getAnnotation(method, WebMethod.class);
    if (webMethod != null && webMethod.exclude())
        return;
    /*
        validations are already done

        if (!Modifier.isPublic(mods) || Modifier.isStatic(mods)) {
            if(webMethod != null) {
                // if the user put @WebMethod on these non-qualifying method,
                // it's an error
                if(Modifier.isStatic(mods))
                    throw new RuntimeModelerException(ModelerMessages.localizableRUNTIME_MODELER_WEBMETHOD_MUST_BE_NONSTATIC(method));
                else
                    throw new RuntimeModelerException(ModelerMessages.localizableRUNTIME_MODELER_WEBMETHOD_MUST_BE_PUBLIC(method));
            }
            return;
        }

        if (webMethod != null && webMethod.exclude())
            return;
*/
    String methodName = method.getName();
    boolean isOneway = (getAnnotation(method, Oneway.class) != null);
    // Check that oneway methods don't thorw any checked exceptions
    if (isOneway) {
        for (Class<?> exception : method.getExceptionTypes()) {
            if (isServiceException(exception)) {
                throw new RuntimeModelerException("runtime.modeler.oneway.operation.no.checked.exceptions", portClass.getCanonicalName(), methodName, exception.getName());
            }
        }
    }
    JavaMethodImpl javaMethod;
    // Class implementorClass = portClass;
    if (method.getDeclaringClass() == portClass) {
        javaMethod = new JavaMethodImpl(model, method, method, metadataReader);
    } else {
        try {
            Method tmpMethod = portClass.getMethod(method.getName(), method.getParameterTypes());
            javaMethod = new JavaMethodImpl(model, tmpMethod, method, metadataReader);
        } catch (NoSuchMethodException e) {
            throw new RuntimeModelerException("runtime.modeler.method.not.found", method.getName(), portClass.getName());
        }
    }
    // set MEP -oneway, async, req/resp
    MEP mep = getMEP(method);
    javaMethod.setMEP(mep);
    String action = null;
    String operationName = method.getName();
    if (webMethod != null) {
        action = webMethod.action();
        operationName = webMethod.operationName().length() > 0 ? webMethod.operationName() : operationName;
    }
    // override the @WebMethod.action value by the one from the WSDL
    if (binding != null) {
        WSDLBoundOperation bo = binding.getBinding().get(new QName(targetNamespace, operationName));
        if (bo != null) {
            WSDLInput wsdlInput = bo.getOperation().getInput();
            String wsaAction = wsdlInput.getAction();
            if (wsaAction != null && !wsdlInput.isDefaultAction())
                action = wsaAction;
            else
                action = bo.getSOAPAction();
        }
    }
    javaMethod.setOperationQName(new QName(targetNamespace, operationName));
    SOAPBinding methodBinding = getAnnotation(method, SOAPBinding.class);
    if (methodBinding != null && methodBinding.style() == SOAPBinding.Style.RPC) {
        logger.warning(ModelerMessages.RUNTIMEMODELER_INVALID_SOAPBINDING_ON_METHOD(methodBinding, method.getName(), method.getDeclaringClass().getName()));
    } else if (methodBinding == null && !method.getDeclaringClass().equals(portClass)) {
        methodBinding = getAnnotation(method.getDeclaringClass(), SOAPBinding.class);
        if (methodBinding != null && methodBinding.style() == SOAPBinding.Style.RPC && methodBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) {
            throw new RuntimeModelerException("runtime.modeler.invalid.soapbinding.parameterstyle", methodBinding, method.getDeclaringClass());
        }
    }
    if (methodBinding != null && defaultBinding.getStyle() != methodBinding.style()) {
        throw new RuntimeModelerException("runtime.modeler.soapbinding.conflict", methodBinding.style(), method.getName(), defaultBinding.getStyle());
    }
    boolean methodIsWrapped = isWrapped;
    Style style = defaultBinding.getStyle();
    if (methodBinding != null) {
        SOAPBindingImpl mySOAPBinding = createBinding(methodBinding);
        style = mySOAPBinding.getStyle();
        if (action != null)
            mySOAPBinding.setSOAPAction(action);
        methodIsWrapped = methodBinding.parameterStyle().equals(SOAPBinding.ParameterStyle.WRAPPED);
        javaMethod.setBinding(mySOAPBinding);
    } else {
        SOAPBindingImpl sb = new SOAPBindingImpl(defaultBinding);
        if (action != null) {
            sb.setSOAPAction(action);
        } else {
            String defaults = SOAPVersion.SOAP_11 == sb.getSOAPVersion() ? "" : null;
            sb.setSOAPAction(defaults);
        }
        javaMethod.setBinding(sb);
    }
    if (!methodIsWrapped) {
        processDocBareMethod(javaMethod, operationName, method);
    } else if (style.equals(Style.DOCUMENT)) {
        processDocWrappedMethod(javaMethod, methodName, operationName, method);
    } else {
        processRpcMethod(javaMethod, methodName, operationName, method);
    }
    model.addJavaMethod(javaMethod);
}
Also used : QName(javax.xml.namespace.QName) SOAPBinding(jakarta.jws.soap.SOAPBinding) Method(java.lang.reflect.Method) WSDLBoundOperation(com.sun.xml.ws.api.model.wsdl.WSDLBoundOperation) WSDLInput(com.sun.xml.ws.api.model.wsdl.WSDLInput) MEP(com.sun.xml.ws.api.model.MEP) Style(jakarta.jws.soap.SOAPBinding.Style) SOAPBindingImpl(com.sun.xml.ws.model.soap.SOAPBindingImpl)

Aggregations

SOAPBindingImpl (com.sun.xml.ws.model.soap.SOAPBindingImpl)2 Style (jakarta.jws.soap.SOAPBinding.Style)2 SOAPVersion (com.sun.xml.ws.api.SOAPVersion)1 MEP (com.sun.xml.ws.api.model.MEP)1 WSDLBoundOperation (com.sun.xml.ws.api.model.wsdl.WSDLBoundOperation)1 WSDLInput (com.sun.xml.ws.api.model.wsdl.WSDLInput)1 SOAPBinding (jakarta.jws.soap.SOAPBinding)1 Method (java.lang.reflect.Method)1 QName (javax.xml.namespace.QName)1