Search in sources :

Example 96 with WebMethod

use of javax.jws.WebMethod in project quickstarts by jboss-switchyard.

the class AirportService method getFLTID.

/**
 * Get flight identifier for the parameters.
 * @param from place (city)
 * @param to place (city)
 * @param date of flight
 * @return format [from/to/month/day]
 */
@WebMethod
@WebResult(name = "fltid")
public String getFLTID(@WebParam(name = "from") String from, @WebParam(name = "to") String to, @WebParam(name = "date") Date date) {
    Calendar c = Calendar.getInstance();
    c.setTime(date);
    return from + "/" + to + "/" + String.valueOf(c.get(Calendar.MONTH) + 1) + "/" + String.valueOf(c.get(Calendar.DAY_OF_MONTH));
}
Also used : Calendar(java.util.Calendar) WebMethod(javax.jws.WebMethod) WebResult(javax.jws.WebResult)

Example 97 with WebMethod

use of javax.jws.WebMethod in project quickstarts by jboss-switchyard.

the class AirportService method order.

/**
 * Order flight ticket defined by fltid for a user identified by name.
 * @param name username
 * @param fltid flight identifier
 */
@WebMethod
public void order(@WebParam(name = "name") String name, @WebParam(name = "fltid") String fltid) {
    log.info("AirportService:order");
    UserTransaction transactionId = UserTransactionFactory.userTransaction();
    if (transactionId != null) {
        log.info("Transaction ID = " + transactionId.toString());
        if (transactionId.toString().compareTo("Unknown") == 0) {
            log.info("JBoss AS is badly configured. (Enable XTS)");
            return;
        }
        // Create order participant (fly ticket)
        OrderParticipant op = new OrderParticipant(transactionId.toString(), fltid);
        try {
            // Enlist order participant to the transaction
            TransactionManagerFactory.transactionManager().enlistForDurableTwoPhase(op, "org.switchyard.quickstarts.bpel.xts.wsat.ws:AirportService:" + name + ":" + fltid);
        } catch (Exception e) {
            log.log(Level.SEVERE, e.getMessage());
            e.printStackTrace();
        }
    }
}
Also used : UserTransaction(com.arjuna.mw.wst11.UserTransaction) WebMethod(javax.jws.WebMethod)

Example 98 with WebMethod

use of javax.jws.WebMethod in project scout.rt by eclipse.

the class InvocationContextTest method testInvokeNotWebMethod.

@Test
public void testInvokeNotWebMethod() {
    final BooleanHolder intercepted = new BooleanHolder(false);
    ServerRunContexts.copyCurrent().withCorrelationId(TESTING_CORRELATION_ID).run(new IRunnable() {

        @Override
        public void run() throws Exception {
            InvocationContext<TestPort> invocationContext = new InvocationContext<>(m_port, "name");
            invocationContext.withEndpointUrl("http://localhost");
            invocationContext.whenInvoke(new InvocationHandler() {

                @Override
                public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                    intercepted.setValue(true);
                    return method.invoke(proxy, args);
                }
            });
            // invoke method which is not annotated with @WebMethod
            invocationContext.getPort().notWebMethod();
        }
    });
    // only methods annotated with @WebMethod are intercepted
    assertFalse(intercepted.getValue());
    // correlationId is not propagated other than web methods
    assertNull(m_port.getRequestContext().get(MessageContexts.PROP_CORRELATION_ID));
    verify(m_port).notWebMethod();
}
Also used : BooleanHolder(org.eclipse.scout.rt.platform.holders.BooleanHolder) IRunnable(org.eclipse.scout.rt.platform.util.concurrent.IRunnable) Method(java.lang.reflect.Method) WebMethod(javax.jws.WebMethod) InvocationHandler(java.lang.reflect.InvocationHandler) Test(org.junit.Test)

Example 99 with WebMethod

use of javax.jws.WebMethod in project jbossws-cxf by jbossws.

the class EndpointOneImpl method echo.

@WebMethod
public String echo(String input) {
    // this is just a verification, so going the dirty way...
    Bus bus = EndpointAssociation.getEndpoint().getService().getDeployment().getAttachment(BusHolder.class).getBus();
    AutomaticWorkQueue queue = bus.getExtension(WorkQueueManager.class).getAutomaticWorkQueue();
    Long qs = null;
    Integer it = null;
    try {
        qs = (Long) queue.getClass().getMethod("getMaxSize").invoke(queue);
        it = (Integer) queue.getClass().getMethod("getHighWaterMark").invoke(queue);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    if (qs != 10) {
        throw new RuntimeException("Expected max queue size '10' but got '" + qs + "'!");
    }
    if (it != 8) {
        throw new RuntimeException("Expected highWaterMark '8' but got '" + it + "'!");
    }
    Logger.getLogger(this.getClass()).info("echo: " + input);
    count.incrementAndGet();
    return input;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Bus(org.apache.cxf.Bus) AutomaticWorkQueue(org.apache.cxf.workqueue.AutomaticWorkQueue) BusHolder(org.jboss.wsf.stack.cxf.configuration.BusHolder) WorkQueueManager(org.apache.cxf.workqueue.WorkQueueManager) WebMethod(javax.jws.WebMethod)

Example 100 with WebMethod

use of javax.jws.WebMethod in project jbossws-cxf by jbossws.

the class EndpointOneImpl method echoOneWay.

@WebMethod
@Oneway
public void echoOneWay(String input) {
    count1.incrementAndGet();
    MessageContext msgContext = context.getMessageContext();
    HttpServletRequest request = (HttpServletRequest) msgContext.get(MessageContext.SERVLET_REQUEST);
    final String scheme = request.getScheme();
    Logger.getLogger(this.getClass()).info("echoOneWay: " + input + ", scheme: " + scheme);
    if (scheme != null) {
        count2.incrementAndGet();
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) MessageContext(javax.xml.ws.handler.MessageContext) WebMethod(javax.jws.WebMethod) Oneway(javax.jws.Oneway)

Aggregations

WebMethod (javax.jws.WebMethod)107 Method (java.lang.reflect.Method)18 Path (javax.ws.rs.Path)17 IOException (java.io.IOException)16 WebResult (javax.jws.WebResult)13 MessageContext (javax.xml.ws.handler.MessageContext)12 WebServiceException (javax.xml.ws.WebServiceException)11 Test (org.junit.Test)10 DataHandler (javax.activation.DataHandler)9 GET (javax.ws.rs.GET)9 Action (javax.xml.ws.Action)9 ArrayList (java.util.ArrayList)8 Oneway (javax.jws.Oneway)8 POST (javax.ws.rs.POST)8 File (java.io.File)7 InputStream (java.io.InputStream)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 QName (javax.xml.namespace.QName)6 RequestWrapper (javax.xml.ws.RequestWrapper)6 AbstractCodeGenTest (org.apache.cxf.tools.wsdlto.AbstractCodeGenTest)6