use of javax.wsdl.Service in project cxf by apache.
the class WSDLManagerImplTest method testBuildSimpleWSDL.
@Test
public void testBuildSimpleWSDL() throws Exception {
String qname = "http://apache.org/hello_world_soap_http";
String wsdlUrl = getClass().getResource("hello_world.wsdl").toString();
WSDLManagerImpl builder = new WSDLManagerImpl();
Definition def = builder.getDefinition(wsdlUrl);
assertNotNull(def);
Map<?, ?> services = def.getServices();
assertNotNull(services);
assertEquals(1, services.size());
Service service = (Service) services.get(new QName(qname, "SOAPService"));
assertNotNull(service);
Map<?, ?> ports = service.getPorts();
assertNotNull(ports);
assertEquals(1, ports.size());
Port port = service.getPort("SoapPort");
assertNotNull(port);
}
use of javax.wsdl.Service in project cxf by apache.
the class WSDLServiceBuilderTest method setUpDefinition.
private void setUpDefinition(String wsdl, int serviceSeq) throws Exception {
URL url = getClass().getResource(wsdl);
assertNotNull("could not find wsdl " + wsdl, url);
String wsdlUrl = url.toString();
LOG.info("the path of wsdl file is " + wsdlUrl);
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
wsdlReader.setFeature("javax.wsdl.verbose", false);
def = wsdlReader.readWSDL(new CatalogWSDLLocator(wsdlUrl));
int seq = 0;
for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
if (serv != null) {
service = serv;
if (seq == serviceSeq) {
break;
}
seq++;
}
}
}
use of javax.wsdl.Service in project cxf by apache.
the class TestBase method getMockedServiceModel.
protected ServiceInfo getMockedServiceModel(String wsdlUrl) throws Exception {
WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
wsdlReader.setFeature("javax.wsdl.verbose", false);
Definition def = wsdlReader.readWSDL(wsdlUrl);
IMocksControl control = EasyMock.createNiceControl();
Bus bus = control.createMock(Bus.class);
BindingFactoryManager bindingFactoryManager = control.createMock(BindingFactoryManager.class);
DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
Service service = null;
for (Iterator<?> it = def.getServices().values().iterator(); it.hasNext(); ) {
Object obj = it.next();
if (obj instanceof Service) {
service = (Service) obj;
break;
}
}
EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
control.replay();
ServiceInfo serviceInfo = wsdlServiceBuilder.buildServices(def, service).get(0);
serviceInfo.setProperty(WSDLServiceBuilder.WSDL_DEFINITION, null);
serviceInfo.setProperty(WSDLServiceBuilder.WSDL_SERVICE, null);
return serviceInfo;
}
use of javax.wsdl.Service in project cxf by apache.
the class JAXBDataBindingTest method setUp.
@Before
public void setUp() throws Exception {
jaxbDataBinding = new JAXBDataBinding();
String wsdlUrl = getClass().getResource(WSDL_PATH).toString();
LOG.info("the path of wsdl file is " + wsdlUrl);
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
wsdlReader.setFeature("javax.wsdl.verbose", false);
def = wsdlReader.readWSDL(wsdlUrl);
control = EasyMock.createNiceControl();
bus = control.createMock(Bus.class);
bindingFactoryManager = control.createMock(BindingFactoryManager.class);
destinationFactoryManager = control.createMock(DestinationFactoryManager.class);
EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andStubReturn(bindingFactoryManager);
EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(destinationFactoryManager);
control.replay();
WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
if (serv != null) {
service = serv;
break;
}
}
wsdlServiceBuilder.buildServices(def, service);
}
use of javax.wsdl.Service in project cxf by apache.
the class WSDLToCorbaBinding method generateCORBAServiceForBinding.
private void generateCORBAServiceForBinding(Definition definition, PortType portType, Binding binding) throws Exception {
if (extReg == null) {
extReg = def.getExtensionRegistry();
}
String interfaceName = portType.getQName().getLocalPart();
interfaceName = mangleInterfaceName(interfaceName);
String serviceName = interfaceName + "CORBAService";
String portName = interfaceName + "CORBAPort";
String prefix = definition.getPrefix(definition.getTargetNamespace());
if (prefix == null) {
prefix = "";
}
String corbaPrefix = definition.getPrefix(CorbaConstants.NU_WSDL_CORBA);
if (corbaPrefix == null) {
corbaPrefix = "corba";
def.addNamespace(corbaPrefix, CorbaConstants.NU_WSDL_CORBA);
}
// Build the service and port information and add it to the wsdl
Service service = def.createService();
Port servicePort = def.createPort();
servicePort.setName(portName);
servicePort.setBinding(binding);
try {
AddressType addressType = (AddressType) def.getExtensionRegistry().createExtension(Port.class, CorbaConstants.NE_CORBA_ADDRESS);
String addr = null;
if (getAddressFile() != null) {
BufferedReader bufferedReader = null;
try {
File addrFile = new File(getAddressFile());
FileReader fileReader = new FileReader(addrFile);
bufferedReader = new BufferedReader(fileReader);
addr = bufferedReader.readLine();
} catch (Exception ex) {
throw new ToolException(ex.getMessage(), ex);
} finally {
if (bufferedReader != null) {
bufferedReader.close();
}
}
} else {
addr = getAddress();
}
if (addr == null) {
addr = "file:./" + interfaceName + ".ref";
}
addressType.setLocation(addr);
servicePort.addExtensibilityElement((ExtensibilityElement) addressType);
} catch (WSDLException ex) {
throw new Exception("Failed to create CORBA address for service", ex);
}
QName serviceQName = new QName(definition.getTargetNamespace(), serviceName, prefix);
service.setQName(serviceQName);
service.addPort(servicePort);
definition.addService(service);
}
Aggregations