Package org.apache.axis2.jaxws.description

Examples of org.apache.axis2.jaxws.description.OperationDescription


                    (WebServiceContext)serviceContext.getProperty(WEBSERVICE_MESSAGE_CONTEXT);
            if (wsc != null) {
                soapMessageContext = (SOAPMessageContext)wsc.getMessageContext();
            }
        }
        OperationDescription op = jaxwsMessageContext.getOperationDescription();

        if (op != null && soapMessageContext != null) {
            soapMessageContext
                    .put(javax.xml.ws.handler.MessageContext.WSDL_OPERATION, op.getName());
            soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.WSDL_OPERATION,
                                        Scope.APPLICATION);
            if (log.isDebugEnabled()) {
                log.debug("WSDL_OPERATION :" + op.getName());
            }

            EndpointInterfaceDescription eid = op.getEndpointInterfaceDescription();
            if (eid != null) {
                EndpointDescription ed = eid.getEndpointDescription();
                QName portType = eid.getPortType();
                if (portType == null || portType.getLocalPart() == "") {
                    if (log.isDebugEnabled()) {
View Full Code Here


                    log.debug("An error occured while invoking the method: " + e.getMessage());
                }
                throw ExceptionFactory.makeWebServiceException(e);
            }
        } else {
            OperationDescription operationDesc =
                    endpointDesc.getEndpointInterfaceDescription().getOperation(method);
            if (isMethodExcluded(operationDesc)) {
                throw ExceptionFactory.makeWebServiceException(
                        Messages.getMessage("proxyExcludedMethod", method.getName()));
            }
View Full Code Here

    private Object invokeSEIMethod(Method method, Object[] args) throws Throwable {
        if (log.isDebugEnabled()) {
            log.debug("Attempting to invoke SEI Method " + method.getName());
        }

        OperationDescription operationDesc =
                endpointDesc.getEndpointInterfaceDescription().getOperation(method);

        // Create and configure the request MessageContext
        InvocationContext requestIC = InvocationContextFactory.createInvocationContext(null);
        MessageContext request = createRequest(method, args);
        request.setEndpointDescription(getEndpointDescription());
        request.setOperationDescription(operationDesc);

        // Enable MTOM on the Message if the property was set on the SOAPBinding.
        Binding bnd = getBinding();
        if (bnd != null && bnd instanceof SOAPBinding) {
            if (((SOAPBinding)bnd).isMTOMEnabled()) {
                Message requestMsg = request.getMessage();
                requestMsg.setMTOMEnabled(true);
            }
        }
       
        /*
         * TODO: review: make sure the handlers are set on the InvocationContext
         * This implementation of the JAXWS runtime does not use Endpoint, which
         * would normally be the place to initialize and store the handler list.
         * In lieu of that, we will have to intialize and store them on the
         * InvocationContext.  also see the InvocationContextFactory.  On the client
         * side, the binding is not yet set when we call into that factory, so the
         * handler list doesn't get set on the InvocationContext object there.  Thus
         * we gotta do it here.
         */
       
        // be sure to use whatever handlerresolver is registered on the Service
        requestIC.setHandlers(bnd.getHandlerChain());

        requestIC.setRequestMessageContext(request);
        requestIC.setServiceClient(serviceDelegate.getServiceClient(endpointDesc.getPortQName()));

        // TODO: Change this to some form of factory so that we can change the IC to
        // a more simple one for marshaller/unmarshaller testing.
        InvocationController controller = new AxisInvocationController();
       
        // Migrate the properties from the client request context bag to
        // the request MessageContext.
        ApplicationContextMigratorUtil.performMigrationToMessageContext(
                Constants.APPLICATION_CONTEXT_MIGRATOR_LIST_ID,
                getRequestContext(), request);

        // Check if the call is OneWay, Async or Sync
        if (operationDesc.isOneWay()) {
            if (log.isDebugEnabled()) {
                log.debug("OneWay Call");
            }
            controller.invokeOneWay(requestIC);

            // Check to see if we need to maintain session state
            checkMaintainSessionState(request, requestIC);
        }

        if (method.getReturnType() == Future.class) {
            if (log.isDebugEnabled()) {
                log.debug("Async Callback");
            }

            //Get AsyncHandler from Objects and sent that to InvokeAsync
            AsyncHandler asyncHandler = null;
            for (Object obj : args) {
                if (obj != null && AsyncHandler.class.isAssignableFrom(obj.getClass())) {
                    asyncHandler = (AsyncHandler)obj;
                    break;
                }
            }

            // Don't allow the invocation to continue if the invocation requires a callback
            // object, but none was supplied.
            if (asyncHandler == null) {
                throw ExceptionFactory
                        .makeWebServiceException(Messages.getMessage("proxyNullCallback"));
            }
            AsyncResponse listener = createProxyListener(args, operationDesc);
            requestIC.setAsyncResponseListener(listener);

            if ((serviceDelegate.getExecutor() != null) &&
                    (serviceDelegate.getExecutor() instanceof ExecutorService)) {
                ExecutorService es = (ExecutorService)serviceDelegate.getExecutor();
                if (es.isShutdown()) {
                    // the executor service is shutdown and won't accept new tasks
                    // so return an error back to the client
                    throw ExceptionFactory
                            .makeWebServiceException(Messages.getMessage("ExecutorShutdown"));
                }
            }

            requestIC.setExecutor(serviceDelegate.getExecutor());

            Future<?> future = controller.invokeAsync(requestIC, asyncHandler);

            //Check to see if we need to maintain session state
            checkMaintainSessionState(request, requestIC);

            return future;
        }

        if (method.getReturnType() == Response.class) {
            if (log.isDebugEnabled()) {
                log.debug("Async Polling");
            }
            AsyncResponse listener = createProxyListener(args, operationDesc);
            requestIC.setAsyncResponseListener(listener);
            requestIC.setExecutor(serviceDelegate.getExecutor());

            Response response = controller.invokeAsync(requestIC);

            //Check to see if we need to maintain session state
            checkMaintainSessionState(request, requestIC);

            return response;
        }

        if (!operationDesc.isOneWay()) {
            InvocationContext responseIC = controller.invoke(requestIC);

            //Check to see if we need to maintain session state
            checkMaintainSessionState(request, requestIC);

View Full Code Here

    protected MessageContext createRequest(Method method, Object[] args) throws Throwable {
        if (log.isDebugEnabled()) {
            log.debug("Creating a new Message using the request parameters.");
        }

        OperationDescription operationDesc =
                endpointDesc.getEndpointInterfaceDescription().getOperation(method);

        Message message = MethodMarshallerFactory.getMarshaller(operationDesc, true)
                .marshalRequest(args, operationDesc);
View Full Code Here

       
        EndpointInterfaceDescription interfaceDesc = endpointDesc.getEndpointInterfaceDescription();
        assertNotNull(interfaceDesc);

        // There should be a single OpDesc with a single AxisOperation with a specific name
        OperationDescription opDescs[] = interfaceDesc.getOperations();
        assertNotNull(opDescs);
        assertEquals(1, opDescs.length);
        AxisOperation axisOperation = opDescs[0].getAxisOperation();
        assertNotNull(axisOperation);
        assertEquals(EndpointInterfaceDescription.JAXWS_NOWSDL_PROVIDER_OPERATION_NAME, axisOperation.getName().getLocalPart());
View Full Code Here

        assertNotNull(interfaceDesc);

        // There should be a single OpDesc with a single AxisOperation based on the SEI below
        // But it should not be the special named operation and the special dispatcher should not
        // return null for operation dispatch
        OperationDescription opDescs[] = interfaceDesc.getOperations();
        assertNotNull(opDescs);
        assertEquals(1, opDescs.length);
        AxisOperation axisOperation = opDescs[0].getAxisOperation();
        assertNotNull(axisOperation);
        if (EndpointInterfaceDescription.JAXWS_NOWSDL_PROVIDER_OPERATION_NAME.equals(axisOperation.getName().getLocalPart())) {
View Full Code Here

            log.debug("Preparing to invoke service endpoint implementation " +
                    "class: " + serviceImplClass.getName());
        }

        initialize(mc);
        OperationDescription operationDesc =
                getOperationDescription(mc); //mc.getOperationDescription();
        //Set SOAP Operation Related properties in SOAPMessageContext.
        ContextUtils.addWSDLProperties(mc);
        Protocol requestProtocol = mc.getMessage().getProtocol();
        MethodMarshaller methodMarshaller =
                getMethodMarshaller(mc.getMessage().getProtocol(), mc.getOperationDescription());
        Object[] methodInputParams =
                methodMarshaller.demarshalRequest(mc.getMessage(), mc.getOperationDescription());
        Method target = getJavaMethod(mc, serviceImplClass);
        if (log.isDebugEnabled()) {
            // At this point, the OpDesc includes everything we know, including the actual method
            // on the service impl we will delegate to; it was set by getJavaMethod(...) above.
            log.debug("JavaBeanDispatcher about to invoke using OperationDesc: " +
                    operationDesc.toString());
        }

        //At this point, we have the method that is going to be invoked and
        //the parameter data to invoke it with, so we use the instance and
        //do the invoke.
        //Passing method input params to grab holder values, if any.
        boolean faultThrown = false;
        Throwable fault = null;
        Object response = null;
        try {
            response = invokeService(mc, target, serviceInstance, methodInputParams);
        } catch (Exception e) {
            faultThrown = true;
            fault = e;
            if (log.isDebugEnabled()) {
                log.debug("Exception invoking a method of " +
                        serviceImplClass.toString() + " of instance " +
                        serviceInstance.toString());
                log.debug("Exception type thrown: " + e.getClass().getName());
                log.debug("Method = " + target.toGenericString());
                for (int i = 0; i < methodInputParams.length; i++) {
                    String value = (methodInputParams[i] == null) ? "null" :
                            methodInputParams[i].getClass().toString();
                    log.debug(" Argument[" + i + "] is " + value);
                }
            }
        }

        Message message = null;
        if (operationDesc.isOneWay()) {
            // If the operation is one-way, then we can just return null because
            // we cannot create a MessageContext for one-way responses.
            return null;
        } else if (faultThrown) {
            message = methodMarshaller.marshalFaultResponse(fault, mc.getOperationDescription(),
                                                            requestProtocol); // Send the response using the same protocol as the request
        } else if (target.getReturnType().getName().equals("void")) {
            message = methodMarshaller
                    .marshalResponse(null, methodInputParams, mc.getOperationDescription(),
                                     requestProtocol); // Send the response using the same protocol as the request
        } else {
            message = methodMarshaller
                    .marshalResponse(response, methodInputParams, mc.getOperationDescription(),
                                     requestProtocol); // Send the response using the same protocol as the request
        }

        MessageContext responseMsgCtx = null;
        if (faultThrown) {
            responseMsgCtx = MessageContextUtils.createFaultMessageContext(mc);
            responseMsgCtx.setMessage(message);

            AxisFault axisFault = new AxisFault("An error was detected during JAXWS processing",
                                              responseMsgCtx.getAxisMessageContext(),
                                              fault);
           
            responseMsgCtx.setCausedByException(axisFault);


        } else {
            responseMsgCtx = MessageContextUtils.createResponseMessageContext(mc);
            responseMsgCtx.setMessage(message);
        }

        //Enable MTOM if necessary
        EndpointInterfaceDescription epInterfaceDesc =
                operationDesc.getEndpointInterfaceDescription();
        EndpointDescription epDesc = epInterfaceDesc.getEndpointDescription();

        String bindingType = epDesc.getBindingType();
        if (bindingType != null) {
            if (bindingType.equals(SOAPBinding.SOAP11HTTP_MTOM_BINDING) ||
View Full Code Here

            // TODO: RAS & NLS
            throw ExceptionFactory.makeWebServiceException(
                    "More than one operation found. Overloaded WSDL operations are not supported.  WSDL Operation name: " +
                            mc.getOperationName());
        }
        OperationDescription op = ops[0];
        if (log.isDebugEnabled()) {
            log.debug("wsdl operation: " + op.getName());
            log.debug("   java method: " + op.getJavaMethodName());
        }

        return op;
    }
View Full Code Here

        return MethodMarshallerFactory.getMarshaller(operationDesc, false);
    }

    private Method getJavaMethod(MessageContext mc, Class serviceImplClass) {

        OperationDescription opDesc = mc.getOperationDescription();
        if (opDesc == null) {
            // TODO: NLS
            throw ExceptionFactory.makeWebServiceException("Operation Description was not set");
        }

        Method returnMethod = opDesc.getMethodFromServiceImpl(serviceImplClass);
        if (returnMethod == null) {
            throw ExceptionFactory
                    .makeWebServiceException(Messages.getMessage("JavaBeanDispatcherErr1"));
        }
View Full Code Here

        // clients do not use operations, so the operationDesc will be null.  In this
        // case an anonymous AxisService with anonymous AxisOperations for the supported
        // MEPs will be created; and it is that anonymous operation name which needs to
        // be specified
        QName operationName = null;
        OperationDescription opDesc = requestMsgCtx.getOperationDescription();
        if (opDesc != null && opDesc.getAxisOperation() != null)
            operationName = opDesc.getName();
        else
            operationName = defaultOpName;
        return operationName;
    }
View Full Code Here

TOP

Related Classes of org.apache.axis2.jaxws.description.OperationDescription

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.