Search in sources :

Example 11 with EndpointImpl

use of org.apache.cxf.jaxws.EndpointImpl in project cxf by apache.

the class ProviderImpl method createEndpoint.

// new in 2.2
public Endpoint createEndpoint(String bindingId, Class<?> implementorClass, Invoker invoker, WebServiceFeature... features) {
    if (EndpointUtils.isValidImplementor(implementorClass)) {
        Bus bus = BusFactory.getThreadDefaultBus();
        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
        if (features != null) {
            factory.getJaxWsServiceFactory().setWsFeatures(Arrays.asList(features));
        }
        if (invoker != null) {
            factory.setInvoker(new JAXWSMethodInvoker(invoker));
            try {
                invoker.inject(new WebServiceContextImpl());
            } catch (Exception e) {
                throw new WebServiceException(new Message("ENDPOINT_CREATION_FAILED_MSG", LOG).toString(), e);
            }
        }
        EndpointImpl ep = new EndpointImpl(bus, null, factory);
        ep.setImplementorClass(implementorClass);
        return ep;
    }
    throw new WebServiceException(new Message("INVALID_IMPLEMENTOR_EXC", LOG).toString());
}
Also used : Bus(org.apache.cxf.Bus) WebServiceException(javax.xml.ws.WebServiceException) Message(org.apache.cxf.common.i18n.Message) EndpointImpl(org.apache.cxf.jaxws.EndpointImpl) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) JAXWSMethodInvoker(org.apache.cxf.jaxws.JAXWSMethodInvoker) WebServiceContextImpl(org.apache.cxf.jaxws.context.WebServiceContextImpl) XMLStreamException(javax.xml.stream.XMLStreamException) PrivilegedActionException(java.security.PrivilegedActionException) JAXBException(javax.xml.bind.JAXBException) WebServiceException(javax.xml.ws.WebServiceException)

Example 12 with EndpointImpl

use of org.apache.cxf.jaxws.EndpointImpl in project cxf by apache.

the class MDBActivationWork method createServerFromJaxwsEndpoint.

/*
     * Creates a server from EndpointImpl so that jaxws-endpoint config can be injected.
     */
private Server createServerFromJaxwsEndpoint(JaxWsServerFactoryBean factory) {
    @SuppressWarnings("resource") EndpointImpl endpoint = new EndpointImpl(factory.getBus(), null, factory);
    endpoint.setWsdlLocation(factory.getWsdlURL());
    endpoint.setImplementorClass(factory.getServiceClass());
    endpoint.setEndpointName(factory.getEndpointName());
    endpoint.setServiceName(factory.getServiceName());
    endpoint.setInvoker(factory.getInvoker());
    endpoint.setSchemaLocations(factory.getSchemaLocations());
    return endpoint.getServer(factory.getAddress());
}
Also used : EndpointImpl(org.apache.cxf.jaxws.EndpointImpl)

Example 13 with EndpointImpl

use of org.apache.cxf.jaxws.EndpointImpl in project cxf by apache.

the class Server method publishEndpoint.

/**
 * If you prefer to define the ConnectionFactory directly instead of using a JNDI look.
 *    // You can inject is like this:
 * @param impl
 * @param cf
 */
protected void publishEndpoint(Object impl, ConnectionFactory cf) {
    EndpointImpl epi = (EndpointImpl) Endpoint.create(impl);
    epi.setFeatures(Collections.singletonList(new ConnectionFactoryFeature(cf)));
    epi.publish();
}
Also used : EndpointImpl(org.apache.cxf.jaxws.EndpointImpl) ConnectionFactoryFeature(org.apache.cxf.transport.jms.ConnectionFactoryFeature)

Example 14 with EndpointImpl

use of org.apache.cxf.jaxws.EndpointImpl in project cxf by apache.

the class JsHttpRequestTest method runTests.

// just one test function to avoid muddles with engine startup/shutdown
@Test
public void runTests() throws Exception {
    testUtilities.rhinoCallExpectingExceptionInContext("SYNTAX_ERR", "testOpaqueURI");
    testUtilities.rhinoCallExpectingExceptionInContext("SYNTAX_ERR", "testNonAbsolute");
    testUtilities.rhinoCallExpectingExceptionInContext("SYNTAX_ERR", "testNonHttp");
    testUtilities.rhinoCallExpectingExceptionInContext("INVALID_STATE_ERR", "testSendNotOpenError");
    testUtilities.rhinoCallInContext("testStateNotificationSync");
    Notifier notifier = testUtilities.rhinoCallConvert("testAsyncHttpFetch1", Notifier.class);
    testUtilities.rhinoCallInContext("testAsyncHttpFetch2");
    boolean notified = notifier.waitForJavascript(2 * 10000);
    assertTrue(notified);
    assertEquals("HEADERS_RECEIVED", Boolean.TRUE, testUtilities.rhinoEvaluateConvert("asyncGotHeadersReceived", Boolean.class));
    assertEquals("LOADING", Boolean.TRUE, testUtilities.rhinoEvaluateConvert("asyncGotLoading", Boolean.class));
    assertEquals("DONE", Boolean.TRUE, testUtilities.rhinoEvaluateConvert("asyncGotDone", Boolean.class));
    String outOfOrder = testUtilities.rhinoEvaluateConvert("outOfOrderError", String.class);
    assertEquals("OutOfOrder", null, outOfOrder);
    assertEquals("status 200", Integer.valueOf(200), testUtilities.rhinoEvaluateConvert("asyncStatus", Integer.class));
    assertEquals("status text", "OK", testUtilities.rhinoEvaluateConvert("asyncStatusText", String.class));
    assertTrue("headers", testUtilities.rhinoEvaluateConvert("asyncResponseHeaders", String.class).contains("Content-Type: text/html"));
    Object httpObj = testUtilities.rhinoCallInContext("testSyncHttpFetch");
    assertNotNull(httpObj);
    assertTrue(httpObj instanceof String);
    String httpResponse = (String) httpObj;
    assertTrue(httpResponse.contains("Test"));
    Reader r = getResourceAsReader("/org/apache/cxf/javascript/XML_GreetMeDocLiteralReq.xml");
    String xml = IOUtils.toString(r);
    EndpointImpl endpoint = this.getBean(EndpointImpl.class, "greeter-service-endpoint");
    JsSimpleDomNode xmlResponse = testUtilities.rhinoCallConvert("testSyncXml", JsSimpleDomNode.class, testUtilities.javaToJS(endpoint.getAddress()), testUtilities.javaToJS(xml));
    assertNotNull(xmlResponse);
    Document doc = (Document) xmlResponse.getWrappedNode();
    testUtilities.addNamespace("t", "http://apache.org/hello_world_xml_http/wrapped/types");
    XPath textPath = XPathAssert.createXPath(testUtilities.getNamespaces());
    String nodeText = (String) textPath.evaluate("//t:responseType/text()", doc, XPathConstants.STRING);
    assertEquals("Hello \u05e9\u05dc\u05d5\u05dd", nodeText);
}
Also used : XPath(javax.xml.xpath.XPath) EndpointImpl(org.apache.cxf.jaxws.EndpointImpl) Reader(java.io.Reader) Document(org.w3c.dom.Document) Notifier(org.apache.cxf.javascript.JavascriptTestUtilities.Notifier) Test(org.junit.Test) AbstractCXFSpringTest(org.apache.cxf.test.AbstractCXFSpringTest)

Example 15 with EndpointImpl

use of org.apache.cxf.jaxws.EndpointImpl in project cxf by apache.

the class ProviderTest method testCXF1852.

@Test
public void testCXF1852() throws Exception {
    try (EndpointImpl ep = new EndpointImpl(getBus(), new PayloadProvider2(), (String) null)) {
        ep.publish("local://localhost:9001/Provider2");
        Node response = invoke("local://localhost:9001/Provider2", LocalTransportFactory.TRANSPORT_ID, "/org/apache/cxf/jaxws/sayHi.xml");
        assertNotNull(response);
        assertNoFault(response);
        addNamespace("j", "http://service.jaxws.cxf.apache.org/");
        assertValid("//s:Body/j:sayHi", response);
    }
}
Also used : EndpointImpl(org.apache.cxf.jaxws.EndpointImpl) Node(org.w3c.dom.Node) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Aggregations

EndpointImpl (org.apache.cxf.jaxws.EndpointImpl)61 QName (javax.xml.namespace.QName)14 Test (org.junit.Test)9 Bus (org.apache.cxf.Bus)8 BeforeClass (org.junit.BeforeClass)7 Bean (org.springframework.context.annotation.Bean)7 Endpoint (javax.xml.ws.Endpoint)5 URL (java.net.URL)4 HashMap (java.util.HashMap)4 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)4 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)4 Feature (org.apache.cxf.feature.Feature)4 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)4 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)3 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 JAXBException (javax.xml.bind.JAXBException)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 WebServiceException (javax.xml.ws.WebServiceException)2