use of javax.wsdl.Service in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method updateEndpoints.
/**
* Clear the actual service endpoints in {@code definition} and use {@code selectedEndpoint} instead of
* actual endpoints.
*
* @param selectedEndpoint Endpoint which will replace the WSDL endpoints
* @param definition WSDL Definition
* @throws APIMgtWSDLException If an error occurred while updating endpoints
*/
private void updateEndpoints(String selectedEndpoint, Definition definition) throws APIMgtWSDLException {
Map serviceMap = definition.getAllServices();
for (Object service : serviceMap.entrySet()) {
Map.Entry svcEntry = (Map.Entry) service;
Service svc = (Service) svcEntry.getValue();
Map portMap = svc.getPorts();
for (Object o : portMap.entrySet()) {
Map.Entry portEntry = (Map.Entry) o;
Port port = (Port) portEntry.getValue();
List extensibilityElementList = port.getExtensibilityElements();
for (Object extensibilityElement : extensibilityElementList) {
setAddressUrl(extensibilityElement, selectedEndpoint);
}
}
}
}
use of javax.wsdl.Service in project carbon-apimgt by wso2.
the class WSDL11ProcessorImpl method getEndpoints.
/**
* Get endpoints defined in the provided WSDL definition.
*
* @param definition WSDL Definition
* @return a Map of endpoint names and their URIs.
* @throws APIMgtWSDLException if error occurs while reading endpoints
*/
private Map<String, String> getEndpoints(Definition definition) throws APIMgtWSDLException {
Map serviceMap = definition.getAllServices();
Iterator serviceItr = serviceMap.entrySet().iterator();
Map<String, String> serviceEndpointMap = new HashMap<>();
while (serviceItr.hasNext()) {
Map.Entry svcEntry = (Map.Entry) serviceItr.next();
Service svc = (Service) svcEntry.getValue();
Map portMap = svc.getPorts();
for (Object o : portMap.entrySet()) {
Map.Entry portEntry = (Map.Entry) o;
Port port = (Port) portEntry.getValue();
List extensibilityElementList = port.getExtensibilityElements();
for (Object extensibilityElement : extensibilityElementList) {
String addressURI = getAddressUrl(extensibilityElement);
serviceEndpointMap.put(port.getName(), addressURI);
}
}
}
return serviceEndpointMap;
}
use of javax.wsdl.Service in project cxf by apache.
the class JAXWSDefinitionBuilderTest method testBuildDefinitionWithXMLBinding.
@Test
public void testBuildDefinitionWithXMLBinding() {
String qname = "http://apache.org/hello_world_xml_http/bare";
String wsdlUrl = getClass().getResource("resources/hello_world_xml_bare.wsdl").toString();
JAXWSDefinitionBuilder builder = new JAXWSDefinitionBuilder();
builder.setBus(BusFactory.getDefaultBus());
builder.setContext(env);
Definition def = builder.build(wsdlUrl);
assertNotNull(def);
Map<?, ?> services = def.getServices();
assertNotNull(services);
assertEquals(1, services.size());
Service service = (Service) services.get(new QName(qname, "XMLService"));
assertNotNull(service);
Map<?, ?> ports = service.getPorts();
assertNotNull(ports);
assertEquals(1, ports.size());
Port port = service.getPort("XMLPort");
assertNotNull(port);
assertEquals(1, port.getExtensibilityElements().size());
Object obj = port.getExtensibilityElements().get(0);
if (obj instanceof JAXBExtensibilityElement) {
obj = ((JAXBExtensibilityElement) obj).getValue();
}
assertTrue(obj.getClass().getName() + " is not an AddressType", obj instanceof AddressType);
Binding binding = port.getBinding();
assertNotNull(binding);
assertEquals(new QName(qname, "Greeter_XMLBinding"), binding.getQName());
BindingOperation operation = binding.getBindingOperation("sayHi", null, null);
assertNotNull(operation);
BindingInput input = operation.getBindingInput();
assertNotNull(input);
assertEquals(1, input.getExtensibilityElements().size());
obj = input.getExtensibilityElements().get(0);
if (obj instanceof JAXBExtensibilityElement) {
obj = ((JAXBExtensibilityElement) obj).getValue();
}
assertTrue(obj.getClass().getName() + " is not an XMLBindingMessageFormat", obj instanceof XMLBindingMessageFormat);
}
use of javax.wsdl.Service in project cxf by apache.
the class WSDLToServiceProcessorTest method testDefaultLocation.
@Test
public void testDefaultLocation() throws Exception {
String[] args = new String[] { "-transport", "soap", "-e", "serviceins", "-p", "portins", "-n", "Greeter_SOAPBinding", "-d", output.getCanonicalPath(), getLocation("/misctools_wsdl/hello_world.wsdl") };
WSDLToService.main(args);
File outputFile = new File(output, "hello_world-service.wsdl");
assertTrue("New wsdl file is not generated", outputFile.exists());
WSDLToServiceProcessor processor = new WSDLToServiceProcessor();
processor.setEnvironment(env);
try {
processor.parseWSDL(outputFile.getAbsolutePath());
Service service = processor.getWSDLDefinition().getService(new QName(processor.getWSDLDefinition().getTargetNamespace(), "serviceins"));
if (service == null) {
fail("Element wsdl:service serviceins Missed!");
}
Iterator<?> it = service.getPort("portins").getExtensibilityElements().iterator();
if (it == null || !it.hasNext()) {
fail("Element wsdl:port portins Missed!");
}
boolean found = false;
while (it.hasNext()) {
Object obj = it.next();
if (obj instanceof SOAPAddress) {
SOAPAddress soapAddress = (SOAPAddress) obj;
if (soapAddress.getLocationURI() != null && soapAddress.getLocationURI().equals("http://localhost:9000/serviceins/portins")) {
found = true;
break;
}
}
}
if (!found) {
fail("Element soap:address of service port Missed!");
}
} catch (ToolException e) {
fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
}
}
use of javax.wsdl.Service in project cxf by apache.
the class WSDLToServiceProcessorTest method testNewServiceSoap12.
@Test
public void testNewServiceSoap12() throws Exception {
String[] args = new String[] { "-soap12", "-transport", "soap", "-e", "SOAPService", "-p", "SoapPort", "-n", "Greeter_SOAPBinding", "-a", "http://localhost:9000/SOAPService/SoapPort", "-d", output.getCanonicalPath(), getLocation("/misctools_wsdl/hello_world_soap12.wsdl") };
WSDLToService.main(args);
File outputFile = new File(output, "hello_world_soap12-service.wsdl");
assertTrue("New wsdl file is not generated", outputFile.exists());
WSDLToServiceProcessor processor = new WSDLToServiceProcessor();
processor.setEnvironment(env);
try {
processor.parseWSDL(outputFile.getAbsolutePath());
Service service = processor.getWSDLDefinition().getService(new QName(processor.getWSDLDefinition().getTargetNamespace(), "SOAPService"));
if (service == null) {
fail("Element wsdl:service serviceins Missed!");
}
Iterator<?> it = service.getPort("SoapPort").getExtensibilityElements().iterator();
if (it == null || !it.hasNext()) {
fail("Element wsdl:port portins Missed!");
}
while (it.hasNext()) {
Object obj = it.next();
if (obj instanceof SOAP12Address) {
SOAP12Address soapAddress = (SOAP12Address) obj;
assertNotNull(soapAddress.getLocationURI());
assertEquals("http://localhost:9000/SOAPService/SoapPort", soapAddress.getLocationURI());
break;
}
}
} catch (ToolException e) {
fail("Exception Encountered when parsing wsdl, error: " + e.getMessage());
}
}
Aggregations