use of javax.wsdl.Service in project tesb-studio-se by Talend.
the class WSDLUtils method getServiceOperationParameters.
public static Map<String, String> getServiceOperationParameters(IFile wsdlURI, String operationName, String portTypeName) throws CoreException {
// NOTE: all below in assuming standalone (no another WSDL's imports) WS-I complaint WSDL !
Map<String, String> map = new HashMap<String, String>();
if (null == wsdlURI) {
// no WSDL provided
return map;
}
Definition wsdl = getDefinition(wsdlURI);
for (Object serviceObject : wsdl.getServices().values()) {
Service service = (Service) serviceObject;
for (Object portObject : service.getPorts().values()) {
Port port = (Port) portObject;
try {
port.getBinding().getPortType().getQName().getLocalPart();
} catch (NullPointerException npe) {
throw getCoreException("WSDL is not consistent. Can not find portType operation description for current service.", npe);
}
if (portTypeName.equals(port.getBinding().getPortType().getQName().getLocalPart())) {
final String targetNs = wsdl.getTargetNamespace();
map.put(SERVICE_NAME, service.getQName().getLocalPart());
map.put(SERVICE_NS, targetNs);
map.put(PORT_NAME, port.getName());
map.put(PORT_NS, targetNs);
map.put(OPERATION_NAME, operationName);
map.put(WSDL_LOCATION, wsdlURI.getLocation().toPortableString());
BindingOperation bindingOperation = port.getBinding().getBindingOperation(operationName, null, null);
if (null == bindingOperation) {
throw getCoreException("Operation '" + operationName + "' not found in binding", null);
}
map.put(COMMUNICATION_STYLE, null == bindingOperation.getBindingOutput() && bindingOperation.getBindingFaults().isEmpty() ? ONE_WAY : REQUEST_RESPONSE);
String faults = null;
for (Object fault : bindingOperation.getBindingFaults().keySet()) {
if (faults == null) {
faults = (String) fault;
} else {
faults += ',' + (String) fault;
}
}
map.put(FAULTS, faults);
// map.put(OPERATION_NS, targetNs);
map.put(ENDPOINT_URI, getPortAddress(port));
break;
}
}
}
return map;
}
use of javax.wsdl.Service in project tomee by apache.
the class WsDeployer method getLocationFromWsdl.
private String getLocationFromWsdl(final Definition definition, final PortComponent portComponent) {
if (definition == null) {
return null;
}
try {
final Service service = definition.getService(portComponent.getWsdlService());
if (service == null) {
return null;
}
final Port port = service.getPort(portComponent.getWsdlPort().getLocalPart());
if (port == null) {
return null;
}
for (final Object element : port.getExtensibilityElements()) {
if (element instanceof SOAPAddress) {
final SOAPAddress soapAddress = (SOAPAddress) element;
final URI uri = URLs.uri(soapAddress.getLocationURI());
return uri.getPath();
} else if (element instanceof HTTPAddress) {
final HTTPAddress httpAddress = (HTTPAddress) element;
final URI uri = URLs.uri(httpAddress.getLocationURI());
return uri.getPath();
}
}
} catch (final Exception e) {
// no-op
}
return null;
}
use of javax.wsdl.Service in project tomee by apache.
the class WsdlVisitor method walkTree.
public void walkTree() {
begin();
try {
visit(definition);
for (Iterator iterator = definition.getImports().entrySet().iterator(); iterator.hasNext(); ) {
Map.Entry entry = (Map.Entry) iterator.next();
String namespaceURI = (String) entry.getKey();
List importsForNamespace = (List) entry.getValue();
for (Iterator iterator1 = importsForNamespace.iterator(); iterator1.hasNext(); ) {
Import anImport = (Import) iterator1.next();
visit(anImport);
}
}
visit(definition.getTypes());
Collection messages = definition.getMessages().values();
for (Iterator iterator = messages.iterator(); iterator.hasNext(); ) {
Message message = (Message) iterator.next();
visit(message);
Collection parts = message.getParts().values();
for (Iterator iterator2 = parts.iterator(); iterator2.hasNext(); ) {
Part part = (Part) iterator2.next();
visit(part);
}
}
Collection services = definition.getServices().values();
for (Iterator iterator = services.iterator(); iterator.hasNext(); ) {
Service service = (Service) iterator.next();
visit(service);
Collection ports = service.getPorts().values();
for (Iterator iterator1 = ports.iterator(); iterator1.hasNext(); ) {
Port port = (Port) iterator1.next();
visit(port);
Binding binding = port.getBinding();
visit(binding);
List bindingOperations = binding.getBindingOperations();
for (int i = 0; i < bindingOperations.size(); i++) {
BindingOperation bindingOperation = (BindingOperation) bindingOperations.get(i);
visit(bindingOperation);
visit(bindingOperation.getBindingInput());
visit(bindingOperation.getBindingOutput());
Collection bindingFaults = bindingOperation.getBindingFaults().values();
for (Iterator iterator2 = bindingFaults.iterator(); iterator2.hasNext(); ) {
BindingFault bindingFault = (BindingFault) iterator2.next();
visit(bindingFault);
}
}
PortType portType = binding.getPortType();
visit(portType);
List operations = portType.getOperations();
for (int i = 0; i < operations.size(); i++) {
Operation operation = (Operation) operations.get(i);
visit(operation);
{
Input input = operation.getInput();
visit(input);
}
{
Output output = operation.getOutput();
visit(output);
}
Collection faults = operation.getFaults().values();
for (Iterator iterator2 = faults.iterator(); iterator2.hasNext(); ) {
Fault fault = (Fault) iterator2.next();
visit(fault);
}
}
}
}
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
} finally {
end();
}
}
Aggregations