use of javax.wsdl.Service in project tesb-studio-se by Talend.
the class ServiceExportManager method createBlueprint.
@SuppressWarnings("unchecked")
public void createBlueprint(File outputFile, Map<ServicePort, Map<String, String>> ports, Map<String, String> additionalInfo, IFile wsdl, String studioServiceName) throws IOException, CoreException {
// TODO: support multiport
Entry<ServicePort, Map<String, String>> studioPort = ports.entrySet().iterator().next();
Definition def = WSDLUtils.getDefinition(wsdl);
QName serviceQName = null;
String endpointAddress = null;
String endpointName = null;
Map<QName, Service> services = def.getServices();
ServicePort servicePort = studioPort.getKey();
for (Entry<QName, Service> serviceEntry : services.entrySet()) {
// TODO: support multi-services
Service service = serviceEntry.getValue();
// TODO: support multi-ports
Collection<Port> servicePorts = service.getPorts().values();
for (Port port : servicePorts) {
if (servicePort.getName().equals(port.getBinding().getPortType().getQName().getLocalPart())) {
serviceQName = serviceEntry.getKey();
endpointName = port.getName();
endpointAddress = WSDLUtils.getPortAddress(port);
if (null != endpointAddress) {
// http://jira.talendforge.org/browse/TESB-3638
final URI uri = URI.create(endpointAddress);
endpointAddress = uri.getPath();
if (endpointAddress == null) {
endpointAddress = uri.getRawSchemeSpecificPart();
int interrogationMark = endpointAddress.indexOf('?');
if (interrogationMark > 0) {
endpointAddress = endpointAddress.substring(0, interrogationMark);
}
}
if (endpointAddress.equals("/services/") || endpointAddress.equals("/services")) {
// pass as is
endpointAddress = endpointAddress;
} else if (endpointAddress.startsWith("/services/")) {
// remove forwarding "/services/" context as required by runtime
// leave
endpointAddress = endpointAddress.substring("/services/".length() - 1);
// forwarding
// slash
} else if (endpointAddress.length() == 1) {
// empty path
endpointAddress += studioServiceName;
}
}
break;
}
}
}
Map<String, Object> endpointInfo = new HashMap<String, Object>();
// $NON-NLS-1$
endpointInfo.put("namespace", serviceQName.getNamespaceURI());
// $NON-NLS-1$
endpointInfo.put("service", serviceQName.getLocalPart());
// $NON-NLS-1$
endpointInfo.put("port", endpointName);
// $NON-NLS-1$
endpointInfo.put("address", endpointAddress);
// $NON-NLS-1$
endpointInfo.put("studioName", studioServiceName);
// $NON-NLS-1$
endpointInfo.put("wsdlLocation", wsdl.getName());
Map<String, String> operation2job = new HashMap<String, String>();
for (Map.Entry<ServicePort, Map<String, String>> port : ports.entrySet()) {
// TODO: actual port work
for (Map.Entry<String, String> operation : port.getValue().entrySet()) {
operation2job.put(operation.getKey(), operation.getValue());
}
}
// $NON-NLS-1$
endpointInfo.put("operation2job", operation2job);
boolean isStudioEEVersion = isStudioEEVersion();
boolean useRegistry = isStudioEEVersion && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.USE_SERVICE_REGISTRY));
boolean useSL = Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.USE_SL));
boolean useSAM = !useRegistry && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.USE_SAM));
boolean useSecurityToken = !useRegistry && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.SECURITY_BASIC));
boolean useSecuritySAML = !useRegistry && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.SECURITY_SAML));
boolean useAuthorization = !useRegistry && isStudioEEVersion && useSecuritySAML && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.AUTHORIZATION));
boolean useEncryption = !useRegistry && isStudioEEVersion && useSecuritySAML && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.ENCRYPTION));
boolean logMessages = Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.LOG_MESSAGES));
boolean wsdlSchemaValidation = isStudioEEVersion && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.WSDL_SCHEMA_VALIDATION));
boolean useBusinessCorrelation = !useRegistry && Boolean.valueOf(additionalInfo.get(ServiceMetadataDialog.USE_BUSINESS_CORRELATION));
// $NON-NLS-1$
endpointInfo.put("useSL", useSL);
// $NON-NLS-1$
endpointInfo.put("useSAM", useSAM);
// $NON-NLS-1$
endpointInfo.put("useSecurityToken", useSecurityToken);
// $NON-NLS-1$
endpointInfo.put("useSecuritySAML", useSecuritySAML);
// $NON-NLS-1$
endpointInfo.put("useAuthorization", useAuthorization);
// $NON-NLS-1$
endpointInfo.put("useEncryption", useEncryption);
// $NON-NLS-1$
endpointInfo.put("useServiceRegistry", useRegistry);
// $NON-NLS-1$
endpointInfo.put("logMessages", logMessages);
// $NON-NLS-1$
endpointInfo.put("useWsdlSchemaValidation", wsdlSchemaValidation);
// $NON-NLS-1$
endpointInfo.put("useBusinessCorrelation", useBusinessCorrelation);
Map<String, String> slCustomProperties = new HashMap<String, String>();
if (useSL) /* && !useRegistry */
{
for (Map.Entry<String, String> prop : additionalInfo.entrySet()) {
if (prop.getKey().startsWith(ServiceMetadataDialog.SL_CUSTOM_PROP_PREFIX)) {
slCustomProperties.put(prop.getKey().substring(ServiceMetadataDialog.SL_CUSTOM_PROP_PREFIX.length()), prop.getValue());
}
}
}
// $NON-NLS-1$
endpointInfo.put("slCustomProps", slCustomProperties);
// $NON-NLS-1$
endpointInfo.put(// $NON-NLS-1$
"samlConfig", // $NON-NLS-1$
serviceQName.toString().replaceAll("\\W+", "_").substring(1));
// $NON-NLS-1$
TemplateProcessor.processTemplate(// $NON-NLS-1$
"DATA_SERVICE_BLUEPRINT_CONFIG", endpointInfo, outputFile, getClass().getResourceAsStream(TEMPLATE_BLUEPRINT));
}
use of javax.wsdl.Service in project Activiti by Activiti.
the class WSDLImporter method importServicesAndOperations.
/**
* Imports services and operations from the WSDL definition
*/
private void importServicesAndOperations(Definition definition) {
for (Object serviceObject : definition.getServices().values()) {
Service service = (Service) serviceObject;
WSService wsService = this.importService(service);
this.wsServices.put(this.namespace + wsService.getName(), wsService);
Port port = (Port) service.getPorts().values().iterator().next();
for (Object bindOperationObject : port.getBinding().getBindingOperations()) {
BindingOperation bindOperation = (BindingOperation) bindOperationObject;
WSOperation operation = this.processOperation(bindOperation.getOperation(), wsService);
wsService.addOperation(operation);
this.wsOperations.put(this.namespace + operation.getName(), operation);
}
}
}
use of javax.wsdl.Service in project cxf by apache.
the class JAXBExtensionHelperTest method checkTestExt.
private void checkTestExt() throws Exception {
Service s = wsdlDefinition.getService(new QName("http://cxf.apache.org/test/hello_world", "HelloWorldService"));
Port p = s.getPort("HelloWorldPort");
List<?> extPortList = p.getExtensibilityElements();
TestPolicyType tp = null;
AnotherPolicyType ap = null;
for (Object ext : extPortList) {
if (ext instanceof TestPolicyType) {
tp = (TestPolicyType) ext;
} else if (ext instanceof AnotherPolicyType) {
ap = (AnotherPolicyType) ext;
} else if (ext instanceof UnknownExtensibilityElement) {
UnknownExtensibilityElement e = (UnknownExtensibilityElement) ext;
System.out.println(e.getElementType());
}
}
assertNotNull("Could not find extension element TestPolicyType", tp);
assertNotNull("Could not find extension element AnotherPolicyType", ap);
assertEquals("Unexpected value for TestPolicyType intAttr", 30, tp.getIntAttr());
assertEquals("Unexpected value for TestPolicyType stringAttr", "hello", tp.getStringAttr());
assertTrue("Unexpected value for AnotherPolicyType floatAttr", Math.abs(0.1F - ap.getFloatAttr()) < 0.5E-5);
}
use of javax.wsdl.Service in project cxf by apache.
the class ServiceWSDLBuilderTest method setupWSDL.
private void setupWSDL(String wsdlPath, boolean doXsdImports) throws Exception {
String wsdlUrl = getClass().getResource(wsdlPath).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);
destinationFactory = control.createMock(DestinationFactory.class);
wsdlServiceBuilder = new WSDLServiceBuilder(bus, false);
for (Service serv : CastUtils.cast(def.getServices().values(), Service.class)) {
if (serv != null) {
service = serv;
break;
}
}
EasyMock.expect(bus.getExtension(WSDLManager.class)).andReturn(new WSDLManagerImpl()).anyTimes();
EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andReturn(destinationFactoryManager);
EasyMock.expect(destinationFactoryManager.getDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/")).andReturn(destinationFactory);
control.replay();
serviceInfo = wsdlServiceBuilder.buildServices(def, service).get(0);
ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, serviceInfo);
builder.setUseSchemaImports(doXsdImports);
builder.setBaseFileName("HelloWorld");
newDef = builder.build(new HashMap<String, SchemaInfo>());
}
use of javax.wsdl.Service in project cxf by apache.
the class ServiceWSDLBuilderTest method testDefinition.
@Test
public void testDefinition() throws Exception {
setupWSDL(WSDL_PATH);
assertEquals(newDef.getTargetNamespace(), "http://apache.org/hello_world_soap_http");
Service serv = newDef.getService(new QName("http://apache.org/hello_world_soap_http", "SOAPService"));
assertNotNull(serv);
assertNotNull(serv.getPort("SoapPort"));
}
Aggregations