use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project cxf by apache.
the class MapsTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
sf.setServiceClass(MapTest.class);
sf.setServiceBean(new MapTestImpl());
sf.setAddress("local://MapTest");
setupAegis(sf);
server = sf.create();
// server.getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
// server.getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
server.start();
JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
proxyFac.setAddress("local://MapTest");
proxyFac.setServiceClass(MapTest.class);
proxyFac.setBus(getBus());
setupAegis(proxyFac.getClientFactoryBean());
clientInterface = (MapTest) proxyFac.create();
}
use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project cxf by apache.
the class DualOutServiceTest method testWSDL.
@Test
public void testWSDL() throws Exception {
JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
sf.setServiceClass(DualOutService.class);
sf.setAddress("local://DualOutService");
sf.setBus(getBus());
setupAegis(sf);
sf.create();
Document wsdl = getWSDLDocument("DualOutService");
assertNotNull(wsdl);
addNamespace("xsd", Constants.URI_2001_SCHEMA_XSD);
assertValid("//xsd:complexType[@name='getValuesResponse']//xsd:element" + "[@name='return'][@type='xsd:string']", wsdl);
assertValid("//xsd:complexType[@name='getValuesResponse']//xsd:element" + "[@name='return1'][@type='xsd:string']", wsdl);
}
use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project cxf by apache.
the class DuplicateArrayTest method testServiceStart.
@Test
public void testServiceStart() throws Exception {
AegisDatabinding binder = new AegisDatabinding();
JaxWsServerFactoryBean serviceFactory = new JaxWsServerFactoryBean();
serviceFactory.getServiceFactory().setDataBinding(binder);
TypeCreationOptions configuration = binder.getAegisContext().getTypeCreationOptions();
configuration.setDefaultMinOccurs(1);
configuration.setDefaultNillable(false);
binder.getAegisContext().setWriteXsiTypes(true);
serviceFactory.setAddress("local://DuplicateArrayService");
serviceFactory.setServiceBean(new DuplicateArrayServiceBean());
serviceFactory.setServiceClass(DuplicateArrayService.class);
Document doc = this.getWSDLDocument(serviceFactory.create());
this.assertValid("//wsdl:definitions/wsdl:types" + "/xsd:schema[@targetNamespace='http://cxf.apache.org/arrays']" + "/xsd:complexType[@name='ArrayOfAnyType']", doc.getDocumentElement());
}
use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project cxf by apache.
the class PolicyAnnotationTest method testAnnotationImplNoInterface.
@org.junit.Test
public void testAnnotationImplNoInterface() throws Exception {
Bus bus = BusFactory.getDefaultBus();
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
factory.setBus(bus);
factory.setServiceBean(new TestImplNoInterface());
factory.setStart(false);
List<String> tp = Arrays.asList("http://schemas.xmlsoap.org/soap/http", "http://schemas.xmlsoap.org/wsdl/http/", "http://schemas.xmlsoap.org/wsdl/soap/http", "http://www.w3.org/2003/05/soap/bindings/HTTP/", "http://cxf.apache.org/transports/http/configuration", "http://cxf.apache.org/bindings/xformat");
LocalTransportFactory f = new LocalTransportFactory();
f.getUriPrefixes().add("http");
f.setTransportIds(tp);
Server s = factory.create();
try {
ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, s.getEndpoint().getService().getServiceInfos());
Definition def = builder.build();
WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter();
def.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtensionRegistry());
Element wsdl = wsdlWriter.getDocument(def).getDocumentElement();
Map<String, String> ns = new HashMap<>();
ns.put("wsdl", WSDLConstants.NS_WSDL11);
ns.put("wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
ns.put("wsp", Constants.URI_POLICY_13_NS);
XPathUtils xpu = new XPathUtils(ns);
// org.apache.cxf.helpers.XMLUtils.printDOM(wsdl);
assertEquals(1, xpu.getValueList("/wsdl:definitions/wsdl:binding/" + "wsp:PolicyReference[@URI='#TestImplNoInterfaceServiceSoapBindingBindingPolicy']", wsdl).getLength());
final EndpointPolicy policy = bus.getExtension(PolicyEngine.class).getServerEndpointPolicy(s.getEndpoint().getEndpointInfo(), null, null);
assertNotNull(policy);
} finally {
bus.shutdown(true);
}
}
use of org.apache.cxf.jaxws.JaxWsServerFactoryBean in project cxf by apache.
the class AbstractDOMProvider method publish.
public void publish() throws Exception {
String addr = epAddress;
String wsdlLoc = null;
String svcNm = null;
String portNm = null;
String tgtNmspc = null;
String binding = null;
Object obj = webSvcProviderVar.get("wsdlLocation", webSvcProviderVar);
if (obj == Scriptable.NOT_FOUND) {
throw new JSDOMProviderException(NO_WSDL_LOCATION);
}
if (obj instanceof String) {
wsdlLoc = (String) obj;
}
obj = webSvcProviderVar.get("serviceName", webSvcProviderVar);
if (obj == Scriptable.NOT_FOUND) {
throw new JSDOMProviderException(NO_SERVICE_NAME);
}
if (obj instanceof String) {
svcNm = (String) obj;
}
obj = webSvcProviderVar.get("portName", webSvcProviderVar);
if (obj == Scriptable.NOT_FOUND) {
throw new JSDOMProviderException(NO_PORT_NAME);
}
if (obj instanceof String) {
portNm = (String) obj;
}
obj = webSvcProviderVar.get("targetNamespace", webSvcProviderVar);
if (obj == Scriptable.NOT_FOUND) {
throw new JSDOMProviderException(NO_TGT_NAMESPACE);
}
if (obj instanceof String) {
tgtNmspc = (String) obj;
}
if (addr == null) {
obj = webSvcProviderVar.get("EndpointAddress", scriptScope);
if (obj != Scriptable.NOT_FOUND && obj instanceof String) {
addr = (String) obj;
isBaseAddr = false;
}
}
if (addr == null) {
throw new JSDOMProviderException(NO_EP_ADDR);
}
if (isBaseAddr) {
if (addr.endsWith("/")) {
addr += portNm;
} else {
addr = addr + "/" + portNm;
}
}
obj = webSvcProviderVar.get("BindingType", scriptScope);
if (obj != Scriptable.NOT_FOUND && obj instanceof String) {
binding = (String) obj;
}
obj = webSvcProviderVar.get("invoke", webSvcProviderVar);
if (obj == Scriptable.NOT_FOUND) {
throw new JSDOMProviderException(NO_INVOKE);
}
if (obj instanceof Function) {
invokeFunc = (Function) obj;
} else {
throw new JSDOMProviderException(ILLEGAL_INVOKE_TYPE);
}
Bus bus = BusFactory.getThreadDefaultBus();
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
factory.setWsdlLocation(wsdlLoc);
factory.setBindingId(binding);
factory.setServiceName(new QName(tgtNmspc, svcNm));
factory.setEndpointName(new QName(tgtNmspc, portNm));
ep = new EndpointImpl(bus, this, factory);
ep.publish(addr);
}
Aggregations