Search in sources :

Example 46 with WebMethod

use of javax.jws.WebMethod in project cxf by apache.

the class AbstractPullPoint method getMessages.

/**
 * @param getMessagesRequest
 * @return returns org.oasis_open.docs.wsn.b_1.GetMessagesResponse
 * @throws ResourceUnknownFault
 * @throws UnableToGetMessagesFault
 */
@WebMethod(operationName = "GetMessages")
@WebResult(name = "GetMessagesResponse", targetNamespace = "http://docs.oasis-open.org/wsn/b-1", partName = "GetMessagesResponse")
public GetMessagesResponse getMessages(@WebParam(name = "GetMessages", targetNamespace = "http://docs.oasis-open.org/wsn/b-1", partName = "GetMessagesRequest") GetMessages getMessagesRequest) throws ResourceUnknownFault, UnableToGetMessagesFault {
    LOGGER.finest("GetMessages");
    BigInteger max = getMessagesRequest.getMaximumNumber();
    List<NotificationMessageHolderType> messages = getMessages(max != null ? max.intValue() : 0);
    GetMessagesResponse response = new GetMessagesResponse();
    response.getNotificationMessage().addAll(messages);
    return response;
}
Also used : GetMessagesResponse(org.oasis_open.docs.wsn.b_2.GetMessagesResponse) BigInteger(java.math.BigInteger) NotificationMessageHolderType(org.oasis_open.docs.wsn.b_2.NotificationMessageHolderType) WebMethod(javax.jws.WebMethod) WebResult(javax.jws.WebResult)

Example 47 with WebMethod

use of javax.jws.WebMethod in project cxf by apache.

the class AbstractSubscription method renew.

/**
 * @param renewRequest
 * @return returns org.oasis_open.docs.wsn.b_1.RenewResponse
 * @throws UnacceptableTerminationTimeFault
 * @throws ResourceUnknownFault
 */
@WebMethod(operationName = "Renew")
@WebResult(name = "RenewResponse", targetNamespace = "http://docs.oasis-open.org/wsn/b-2", partName = "RenewResponse")
public RenewResponse renew(@WebParam(name = "Renew", targetNamespace = "http://docs.oasis-open.org/wsn/b-2", partName = "RenewRequest") Renew renewRequest) throws ResourceUnknownFault, UnacceptableTerminationTimeFault {
    XMLGregorianCalendar time = validateTerminationTime(renewRequest.getTerminationTime());
    this.setTerminationTime(time);
    renew(time);
    RenewResponse response = new RenewResponse();
    response.setTerminationTime(time);
    response.setCurrentTime(getCurrentTime());
    return response;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) RenewResponse(org.oasis_open.docs.wsn.b_2.RenewResponse) WebMethod(javax.jws.WebMethod) WebResult(javax.jws.WebResult)

Example 48 with WebMethod

use of javax.jws.WebMethod in project quickstart by wildfly.

the class SetServiceBAImpl method addValueToSet.

/**
 * Add an item to a set Enrolls a Participant if necessary and passes the call through to the business logic.
 *
 * @param value the value to add to the set.
 * @throws AlreadyInSetException if value is already in the set
 * @throws SetServiceException if an error occurred when attempting to add the item to the set.
 */
@WebMethod
public void addValueToSet(String value) throws AlreadyInSetException, SetServiceException {
    System.out.println("[SERVICE] invoked addValueToSet('" + value + "')");
    BAParticipantManager participantManager;
    try {
        // enlist the Participant for this service:
        SetParticipantBA participant = new SetParticipantBA(value);
        BusinessActivityManager activityManager = BusinessActivityManagerFactory.businessActivityManager();
        System.out.println("[SERVICE] Enlisting a participant into the BA");
        participantManager = activityManager.enlistForBusinessAgreementWithParticipantCompletion(participant, "SetServiceBAImpl:" + UUID.randomUUID());
    } catch (Exception e) {
        System.err.println("Participant enlistment failed");
        e.printStackTrace(System.err);
        throw new SetServiceException("Error enlisting participant", e);
    }
    // invoke the back-end business logic
    System.out.println("[SERVICE] Invoking the back-end business logic");
    MockSetManager.add(value);
    /*
         * this service employs the participant completion protocol which means it decides when it wants to commit local
         * changes. If the local changes (adding the item to the set) succeeded, we notify the coordinator that we have
         * completed. Otherwise, we notify the coordinator that we cannot complete. If any other participant fails or the client
         * decides to cancel we can rely upon being told to compensate.
         */
    System.out.println("[SERVICE] Prepare the backend resource and if successful notify the coordinator that we have completed our work");
    if (MockSetManager.prepare()) {
        try {
            // tell the coordinator manager we have finished our work
            System.out.println("[SERVICE] Prepare successful, notifying coordinator of completion");
            participantManager.completed();
        } catch (Exception e) {
            /*
                 * Failed to notify the coordinator that we have finished our work. Compensate the work and throw an Exception
                 * to notify the client that the add operation failed.
                 */
            MockSetManager.rollback(value);
            System.err.println("[SERVICE]  'completed' callback failed");
            throw new SetServiceException("Error when notifying the coordinator that the work is completed", e);
        }
    } else {
        try {
            /*
                 * tell the participant manager we cannot complete. this will force the activity to fail
                 */
            System.out.println("[SERVICE] Prepare failed, notifying coordinator that we cannot complete");
            participantManager.cannotComplete();
        } catch (Exception e) {
            System.err.println("'cannotComplete' callback failed");
            throw new SetServiceException("Error when notifying the coordinator that the work is cannot be completed", e);
        }
        throw new SetServiceException("Unable to prepare the back-end resource");
    }
}
Also used : BusinessActivityManager(com.arjuna.mw.wst11.BusinessActivityManager) BAParticipantManager(com.arjuna.wst11.BAParticipantManager) WebMethod(javax.jws.WebMethod)

Aggregations

WebMethod (javax.jws.WebMethod)48 Method (java.lang.reflect.Method)13 WebResult (javax.jws.WebResult)12 Test (org.junit.Test)7 File (java.io.File)6 IOException (java.io.IOException)6 AbstractCodeGenTest (org.apache.cxf.tools.wsdlto.AbstractCodeGenTest)6 ActionExecutionException (com.axway.ats.agent.core.exceptions.ActionExecutionException)5 AgentException (com.axway.ats.agent.core.exceptions.AgentException)5 InternalComponentException (com.axway.ats.agent.core.exceptions.InternalComponentException)5 NoCompatibleMethodFoundException (com.axway.ats.agent.core.exceptions.NoCompatibleMethodFoundException)5 NoSuchActionException (com.axway.ats.agent.core.exceptions.NoSuchActionException)5 NoSuchComponentException (com.axway.ats.agent.core.exceptions.NoSuchComponentException)5 Path (javax.ws.rs.Path)5 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)4 QName (javax.xml.namespace.QName)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ObjectOutputStream (java.io.ObjectOutputStream)3 ArrayList (java.util.ArrayList)3 GET (javax.ws.rs.GET)3