use of org.apache.cxf.service.Service in project cxf by apache.
the class TestUtils method setupServiceInfo.
public EndpointInfo setupServiceInfo(String ns, String wsdl, String serviceName, String portName) throws Exception {
URL wsdlUrl = getClass().getResource(wsdl);
WSDLServiceFactory f = new WSDLServiceFactory(bus, wsdlUrl.toString(), new QName(ns, serviceName));
Service service = f.create();
return service.getEndpointInfo(new QName(ns, portName));
}
use of org.apache.cxf.service.Service in project cxf by apache.
the class ContextUtils method getDataWriter.
public static DataWriter<XMLEventWriter> getDataWriter(CorbaMessage message) {
Service service = ServiceModelUtil.getService(message.getExchange());
DataWriter<XMLEventWriter> dataWriter = service.getDataBinding().createWriter(XMLEventWriter.class);
if (dataWriter == null) {
// throw a fault
// throw new Fault(new org.apache.cxf.common.i18n.Message("NO_DATAWRITER", BUNDLE, service
// .getName()));
}
return dataWriter;
}
use of org.apache.cxf.service.Service in project cxf by apache.
the class ExceptionTest method testJaxws.
@Test(expected = HelloException.class)
public void testJaxws() throws Exception {
JaxWsServerFactoryBean sfbean = new JaxWsServerFactoryBean();
sfbean.setServiceClass(ExceptionService.class);
setupAegis(sfbean);
sfbean.setAddress("local://ExceptionService4");
Server server = sfbean.create();
Service service = server.getEndpoint().getService();
service.setInvoker(new BeanInvoker(new ExceptionServiceImpl()));
JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
proxyFac.setAddress("local://ExceptionService4");
proxyFac.setBus(getBus());
setupAegis(proxyFac.getClientFactoryBean());
ExceptionService clientInterface = proxyFac.create(ExceptionService.class);
clientInterface.sayHiWithException();
}
use of org.apache.cxf.service.Service in project cxf by apache.
the class ExceptionTest method testJaxwsServerSimpleClient.
@Test(expected = HelloException.class)
public void testJaxwsServerSimpleClient() throws Exception {
JaxWsServerFactoryBean sfbean = new JaxWsServerFactoryBean();
sfbean.setServiceClass(ExceptionService.class);
sfbean.setDataBinding(new AegisDatabinding());
sfbean.setAddress("local://ExceptionServiceJaxWs1");
Server server = sfbean.create();
Service service = server.getEndpoint().getService();
service.setInvoker(new BeanInvoker(new ExceptionServiceImpl()));
ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
proxyFac.setAddress("local://ExceptionServiceJaxWs1");
proxyFac.setBus(getBus());
setupAegis(proxyFac.getClientFactoryBean());
ExceptionService clientInterface = proxyFac.create(ExceptionService.class);
clientInterface.sayHiWithException();
}
use of org.apache.cxf.service.Service in project cxf by apache.
the class ServiceImpl method initializePorts.
private void initializePorts() {
try {
Definition def = bus.getExtension(WSDLManager.class).getDefinition(wsdlURL);
javax.wsdl.Service serv = def.getService(serviceName);
if (serv == null) {
throw new WebServiceException("Could not find service named " + serviceName + " in wsdl " + wsdlURL);
}
Map<String, Port> wsdlports = CastUtils.cast(serv.getPorts());
for (Port port : wsdlports.values()) {
QName name = new QName(serviceName.getNamespaceURI(), port.getName());
String address = null;
String bindingID = null;
List<? extends ExtensibilityElement> extensions = CastUtils.cast(port.getBinding().getExtensibilityElements());
if (!extensions.isEmpty()) {
ExtensibilityElement e = extensions.get(0);
if (e instanceof SoapBinding) {
bindingID = SOAPBinding.SOAP11HTTP_BINDING;
} else if (e instanceof SOAP12Binding) {
bindingID = SOAPBinding.SOAP12HTTP_BINDING;
} else if (e instanceof javax.wsdl.extensions.soap.SOAPBinding) {
bindingID = SOAPBinding.SOAP11HTTP_BINDING;
}
}
extensions = CastUtils.cast(port.getExtensibilityElements());
if (!extensions.isEmpty()) {
ExtensibilityElement e = extensions.get(0);
if (e instanceof SoapAddress) {
address = ((SoapAddress) e).getLocationURI();
} else if (e instanceof AddressType) {
address = ((AddressType) e).getLocation();
} else if (e instanceof SOAP12Address) {
address = ((SOAP12Address) e).getLocationURI();
} else if (e instanceof SOAPAddress) {
address = ((SOAPAddress) e).getLocationURI();
} else if (e instanceof HTTPAddress) {
address = ((HTTPAddress) e).getLocationURI();
}
}
addPort(name, bindingID, address);
}
} catch (WebServiceException e) {
throw e;
} catch (Throwable e) {
if (e instanceof UncheckedException && LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, e.getLocalizedMessage(), e);
}
WSDLServiceFactory sf = new WSDLServiceFactory(bus, wsdlURL, serviceName);
Service service = sf.create();
for (ServiceInfo si : service.getServiceInfos()) {
for (EndpointInfo ei : si.getEndpoints()) {
String bindingID = BindingID.getJaxwsBindingID(ei.getTransportId());
addPort(ei.getName(), bindingID, ei.getAddress());
}
}
}
}
Aggregations