Search in sources :

Example 1 with EventSourceEndpoint

use of org.apache.cxf.ws.eventing.eventsource.EventSourceEndpoint in project cxf by apache.

the class CreateSubscriptionServlet method doGet.

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    try {
        resp.getWriter().append("<html><body>");
        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
        factory.setServiceClass(EventSourceEndpoint.class);
        factory.setAddress("http://localhost:8080/ws_eventing/services/EventSource");
        EventSourceEndpoint requestorClient = (EventSourceEndpoint) factory.create();
        String expires = null;
        if (req.getParameter("expires-set") == null) {
            expires = req.getParameter("expires");
        } else {
            if (!req.getParameter("expires-set").equals("false")) {
                expires = req.getParameter("expires");
            }
        }
        Subscribe sub = createSubscribeMessage(req.getParameter("targeturl"), req.getParameter("filter-set") == null ? req.getParameter("filter") : null, expires);
        resp.getWriter().append("<h3>Subscription request</h3>");
        resp.getWriter().append(convertJAXBElementToStringAndEscapeHTML(sub));
        SubscribeResponse subscribeResponse = requestorClient.subscribeOp(sub);
        resp.getWriter().append("<h3>Response from Event Source</h3>");
        resp.getWriter().append(convertJAXBElementToStringAndEscapeHTML(subscribeResponse));
        resp.getWriter().append("<br/><a href=\"index.jsp\">Back to main page</a>");
        resp.getWriter().append("</body></html>");
    } catch (Exception e) {
        throw new ServletException(e);
    }
}
Also used : ServletException(javax.servlet.ServletException) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) EventSourceEndpoint(org.apache.cxf.ws.eventing.eventsource.EventSourceEndpoint) Subscribe(org.apache.cxf.ws.eventing.Subscribe) SubscribeResponse(org.apache.cxf.ws.eventing.SubscribeResponse) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) JAXBException(javax.xml.bind.JAXBException)

Aggregations

IOException (java.io.IOException)1 ServletException (javax.servlet.ServletException)1 JAXBException (javax.xml.bind.JAXBException)1 DatatypeConfigurationException (javax.xml.datatype.DatatypeConfigurationException)1 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)1 Subscribe (org.apache.cxf.ws.eventing.Subscribe)1 SubscribeResponse (org.apache.cxf.ws.eventing.SubscribeResponse)1 EventSourceEndpoint (org.apache.cxf.ws.eventing.eventsource.EventSourceEndpoint)1