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());
}
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());
}
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();
}
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);
}
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);
}
}
Aggregations