use of javax.wsdl.Service in project cxf by apache.
the class WSDLToCorbaBindingTypeTest method testSetCorbaAddress.
@Test
public void testSetCorbaAddress() throws Exception {
try {
String fileName = getClass().getResource("/wsdl/datetime.wsdl").toString();
generator.setWsdlFile(fileName);
generator.addInterfaceName("BasePortType");
Definition model = generator.generateCORBABinding();
QName name = new QName("http://schemas.apache.org/idl/datetime.idl", "BaseCORBAService", "tns");
Service service = model.getService(name);
Port port = service.getPort("BaseCORBAPort");
AddressType addressType = (AddressType) port.getExtensibilityElements().get(0);
String address = addressType.getLocation();
assertEquals("file:./Base.ref", address);
generator.setAddress("corbaloc::localhost:40000/hw");
model = generator.generateCORBABinding();
service = model.getService(name);
port = service.getPort("BaseCORBAPort");
addressType = (AddressType) port.getExtensibilityElements().get(0);
address = addressType.getLocation();
assertEquals("corbaloc::localhost:40000/hw", address);
} finally {
new File("datetime-corba.wsdl").deleteOnExit();
}
}
use of javax.wsdl.Service in project cxf by apache.
the class ServiceModelUtilTest method setUp.
@Before
public void setUp() throws Exception {
String wsdlUrl = getClass().getResource(WSDL_PATH).toString();
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
wsdlReader.setFeature("javax.wsdl.verbose", false);
def = wsdlReader.readWSDL(wsdlUrl);
WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
if (serv != null) {
service = serv;
break;
}
}
control = EasyMock.createNiceControl();
bus = control.createMock(Bus.class);
bindingFactoryManager = control.createMock(BindingFactoryManager.class);
wsdlServiceBuilder = new WSDLServiceBuilder(bus);
EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
control.replay();
serviceInfo = wsdlServiceBuilder.buildServices(def, service).get(0);
}
use of javax.wsdl.Service in project cxf by apache.
the class ServiceWSDLBuilder method buildService.
protected void buildService(ServiceInfo serviceInfo, Definition definition) {
Map<QName, MessageInfo> messages = serviceInfo.getMessages();
for (Map.Entry<QName, MessageInfo> mie : messages.entrySet()) {
if (!mie.getKey().getNamespaceURI().equals(definition.getTargetNamespace())) {
continue;
}
if (definition.getMessage(mie.getKey()) != null) {
continue;
}
Message message = definition.createMessage();
addDocumentation(message, mie.getValue().getMessageDocumentation());
message.setUndefined(false);
message.setQName(mie.getKey());
for (MessagePartInfo mpi : mie.getValue().getMessageParts()) {
Part part = definition.createPart();
boolean elemental = mpi.isElement();
// RFSB will turn on isElement bogusly.
if (elemental && null == serviceInfo.getXmlSchemaCollection().getElementByQName(mpi.getElementQName())) {
elemental = false;
}
if (elemental) {
part.setElementName(mpi.getElementQName());
} else {
part.setTypeName(mpi.getTypeQName());
}
part.setName(mpi.getName().getLocalPart());
message.addPart(part);
}
definition.addMessage(message);
}
addDocumentation(definition, serviceInfo.getTopLevelDoc());
Service serv = definition.createService();
addDocumentation(serv, serviceInfo.getDocumentation());
serv.setQName(serviceInfo.getName());
addNamespace(serviceInfo.getName().getNamespaceURI(), definition);
addExtensibilityElements(definition, serv, getWSDL11Extensors(serviceInfo));
definition.addService(serv);
for (EndpointInfo ei : serviceInfo.getEndpoints()) {
addNamespace(ei.getTransportId(), definition);
Port port = definition.createPort();
addDocumentation(port, ei.getDocumentation());
port.setName(ei.getName().getLocalPart());
port.setBinding(definition.getBinding(ei.getBinding().getName()));
addExtensibilityElements(definition, port, getWSDL11Extensors(ei));
serv.addPort(port);
}
}
use of javax.wsdl.Service in project cxf by apache.
the class WSDLManagerImplTest method testBuildImportedWSDL.
@Test
public void testBuildImportedWSDL() throws Exception {
String wsdlUrl = getClass().getResource("hello_world_services.wsdl").toString();
WSDLManagerImpl builder = new WSDLManagerImpl();
Definition def = builder.getDefinition(wsdlUrl);
assertNotNull(def);
Map<?, ?> services = def.getServices();
assertNotNull(services);
assertEquals(1, services.size());
String serviceQName = "http://apache.org/hello_world/services";
Service service = (Service) services.get(new QName(serviceQName, "SOAPService"));
assertNotNull(service);
Map<?, ?> ports = service.getPorts();
assertNotNull(ports);
assertEquals(1, ports.size());
Port port = service.getPort("SoapPort");
assertNotNull(port);
Binding binding = port.getBinding();
assertNotNull(binding);
QName bindingQName = new QName("http://apache.org/hello_world/bindings", "SOAPBinding");
assertEquals(bindingQName, binding.getQName());
PortType portType = binding.getPortType();
assertNotNull(portType);
QName portTypeQName = new QName("http://apache.org/hello_world", "Greeter");
assertEquals(portTypeQName, portType.getQName());
Operation op1 = portType.getOperation("sayHi", "sayHiRequest", "sayHiResponse");
assertNotNull(op1);
QName messageQName = new QName("http://apache.org/hello_world/messages", "sayHiRequest");
assertEquals(messageQName, op1.getInput().getMessage().getQName());
Part part = op1.getInput().getMessage().getPart("in");
assertNotNull(part);
assertEquals(new QName("http://apache.org/hello_world/types", "sayHi"), part.getElementName());
}
use of javax.wsdl.Service in project cxf by apache.
the class CorbaObjectReferenceHelper method getEndpointName.
public static String getEndpointName(Binding binding, Definition wsdlDef) {
LOG.log(Level.FINE, "Getting endpoint name for an object reference");
Collection<Service> services = CastUtils.cast(wsdlDef.getServices().values());
for (Service serv : services) {
Collection<Port> ports = CastUtils.cast(serv.getPorts().values());
for (Port pt : ports) {
if (pt.getBinding().equals(binding)) {
return pt.getName();
}
}
}
return null;
}
Aggregations