Search in sources :

Example 1 with PayloadRoot

use of org.springframework.ws.server.endpoint.annotation.PayloadRoot in project webservices-axiom by apache.

the class BrokerEndpoint method order.

@PayloadRoot(namespace = "urn:broker", localPart = "Order")
@ResponsePayload
@Namespaces(@Namespace(prefix = "p", uri = "urn:broker"))
public OrderStatus order(@XPathParam("/p:Order/p:Customer") Integer customer, @RequestPayload Source payloadSource) throws UnknownCustomerException, TransformerException {
    customerService.validateCustomer(customer);
    StringWriter sw = new StringWriter();
    transformerHelper.transform(payloadSource, new StreamResult(sw));
    String payload = sw.toString();
    synchronized (orderQueue) {
        orderQueue.addLast(payload);
        orderQueue.notify();
    }
    OrderStatus status = new OrderStatus();
    status.setReceived(new Date());
    return status;
}
Also used : StringWriter(java.io.StringWriter) StreamResult(javax.xml.transform.stream.StreamResult) Date(java.util.Date) Namespaces(org.springframework.ws.server.endpoint.annotation.Namespaces) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 2 with PayloadRoot

use of org.springframework.ws.server.endpoint.annotation.PayloadRoot in project webservices-axiom by apache.

the class CalculatorEndpoint method add.

@PayloadRoot(namespace = NAMESPACE_URI, localPart = "AddRequest")
@ResponsePayload
public Element add(@RequestPayload Element addRequest) throws Exception {
    log.debug("Endpoint invoked");
    double sum = 0d;
    for (Element operand : operandExpression.evaluate(addRequest)) {
        sum += Double.parseDouble(operand.getTextNormalize());
    }
    Element response = new Element("AddResponse", NAMESPACE);
    response.setText(String.valueOf(sum));
    return response;
}
Also used : Element(org.jdom2.Element) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 3 with PayloadRoot

use of org.springframework.ws.server.endpoint.annotation.PayloadRoot in project spring-boot by spring-projects.

the class HolidayEndpoint method handleHolidayRequest.

@PayloadRoot(namespace = NAMESPACE_URI, localPart = "HolidayRequest")
public void handleHolidayRequest(@RequestPayload Element holidayRequest) throws Exception {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    Date startDate = dateFormat.parse(this.startDateExpression.evaluateFirst(holidayRequest).getText());
    Date endDate = dateFormat.parse(this.endDateExpression.evaluateFirst(holidayRequest).getText());
    String name = this.nameExpression.evaluateFirst(holidayRequest);
    this.humanResourceService.bookHoliday(startDate, endDate, name);
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 4 with PayloadRoot

use of org.springframework.ws.server.endpoint.annotation.PayloadRoot in project OpenClinica by OpenClinica.

the class StudySubjectEndpoint method listStudySubjectsInStudy.

/**
 * Use this method to list all study subjects. Scheduled event data will also be show if available.
 *
 * @param requestElement
 * @return ListAllByStudyResponse
 * @throws Exception
 */
@PayloadRoot(localPart = "listAllByStudyRequest", namespace = NAMESPACE_URI_V1)
public ListAllByStudyResponse listStudySubjectsInStudy(JAXBElement<ListStudySubjectsInStudyType> requestElement) throws Exception {
    try {
        ResourceBundleProvider.updateLocale(new Locale("en_US"));
        ListStudySubjectsInStudyType listStudySubjectsInStudyType = requestElement.getValue();
        StudyBean study = null;
        try {
            study = validateRequestAndReturnStudy(listStudySubjectsInStudyType.getStudyRef());
        } catch (OpenClinicaSystemException e) {
            e.printStackTrace();
            ListAllByStudyResponse response = new ListAllByStudyResponse();
            response.setResult(messages.getMessage("studySubjectEndpoint.fail", null, "Fail", locale));
            response.getError().add(messages.getMessage(e.getErrorCode(), null, e.getErrorCode(), locale));
            return response;
        }
        return mapListStudySubjectsInStudyResponse(study, messages.getMessage("studySubjectEndpoint.success", null, "Success", locale), listStudySubjectsInStudyType.getStudyRef());
    } catch (Exception eee) {
        eee.printStackTrace();
        throw eee;
    }
}
Also used : Locale(java.util.Locale) ListStudySubjectsInStudyType(org.openclinica.ws.beans.ListStudySubjectsInStudyType) ListAllByStudyResponse(org.openclinica.ws.studysubject.v1.ListAllByStudyResponse) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException) ParseException(java.text.ParseException) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Example 5 with PayloadRoot

use of org.springframework.ws.server.endpoint.annotation.PayloadRoot in project OpenClinica by OpenClinica.

the class CctsSubjectEndpoint method rollBackSubject.

/**
 * if NAMESPACE_URI_V1:commitRequest execute this method
 * @param gridId
 * @param subject
 * @param studyOid
 * @return
 * @throws Exception
 */
@PayloadRoot(localPart = "rollbackRequest", namespace = NAMESPACE_URI_V1)
public Source rollBackSubject(@XPathParam("//s:gridId") String gridId, @XPathParam("//s:subject") NodeList subject, @XPathParam("//s:study/@oid") String studyOid) throws Exception {
    Element subjectElement = (Element) (subject.item(0));
    SubjectTransferBean subjectTranferBean = unMarshallToSubjectTransfer(gridId, subjectElement, studyOid);
    // TODO: Add Logic
    return new DOMSource(mapConfirmation(SUCCESS_MESSAGE));
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) Element(org.w3c.dom.Element) SubjectTransferBean(org.akaza.openclinica.bean.managestudy.SubjectTransferBean) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Aggregations

PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)12 DOMSource (javax.xml.transform.dom.DOMSource)6 Element (org.w3c.dom.Element)6 DataBinder (org.springframework.validation.DataBinder)4 Errors (org.springframework.validation.Errors)4 ParseException (java.text.ParseException)3 Date (java.util.Date)3 Locale (java.util.Locale)3 SubjectTransferBean (org.akaza.openclinica.bean.managestudy.SubjectTransferBean)3 SimpleDateFormat (java.text.SimpleDateFormat)2 JAXBElement (javax.xml.bind.JAXBElement)2 OpenClinicaSystemException (org.akaza.openclinica.exception.OpenClinicaSystemException)2 BaseStudyDefinitionBean (org.akaza.openclinica.ws.bean.BaseStudyDefinitionBean)2 SubjectTransferValidator (org.akaza.openclinica.ws.validator.SubjectTransferValidator)2 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)2 FileOutputStream (java.io.FileOutputStream)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 StreamResult (javax.xml.transform.stream.StreamResult)1