List of usage examples for javax.xml.ws Service create
public static Service create(QName serviceName, WebServiceFeature... features)
From source file:eu.planets_project.tb.impl.services.wrappers.ComparePropertiesWrapper.java
/** * /* ww w.j ava 2s . c o m*/ */ private void init() { service = Service.create(pse.getWsdlLocation(), pse.getQName()); try { c = (CompareProperties) service.getPort(pse.getServiceClass()); } catch (Exception e) { log.error("Failed to instanciate service " + pse.getQName() + " at " + pse.getWsdlLocation() + " : Exception - " + e); e.printStackTrace(); c = null; } }
From source file:eu.planets_project.tb.impl.services.util.DiscoveryUtils.java
/** * A generic method that can be used as a short-cut for instanciating Planets services. * //from w w w . j a va 2s. c o m * e.g. Migrate m = DiscoveryUtils.createServiceClass( Migrate.class, wsdlLocation); * * If the given WSDL points to one of the older 'Basic' service forms, it will be wrapped up * to present the new API and hide the old one. * * @param <T> Any recognised service class (extends PlanetsService). * @param serviceClass The class of the Planets service to instanciate, e.g. Identify.class * @param wsdlLocation The location of the WSDL. * @return A new instance of the the given class, wrapping the referenced service. */ public static <T> T createServiceObject(Class<T> serviceClass, URL wsdlLocation) { PlanetsServiceExplorer se = new PlanetsServiceExplorer(wsdlLocation); Service service; if (serviceClass == null || wsdlLocation == null) return null; service = Service.create(wsdlLocation, se.getQName()); return (T) service.getPort(serviceClass); }
From source file:com.microsoft.exchange.ExchangeWebService.java
public ExchangeWebService(boolean logging) { this.logging = logging; URL wsdlUrl = ExchangeWebService.class.getResource("exchange.wsdl"); service = Service.create(wsdlUrl, SERVICE); }
From source file:org.jboss.as.test.integration.ws.authentication.EJBEndpointSecuredWSDLAccessTestCase.java
@Test public void createService() throws Exception { QName serviceName = new QName("http://jbossws.org/authenticationForWSDL", "EJB3ServiceForWSDL"); URL wsdlURL = new URL(baseUrl, "/jaxws-authentication-ejb3-for-wsdl/EJB3ServiceForWSDL?wsdl"); try {/*from ww w.j a va 2s. c om*/ Service service = Service.create(wsdlURL, serviceName); EJBEndpointIface proxy = service.getPort(EJBEndpointIface.class); Assert.fail("Proxy shouldn't be created because WSDL access should be secured"); } catch (WebServiceException e) { // failure is expected } }
From source file:eu.planets_project.pp.plato.services.action.planets.PlanetsMigrationService.java
/** * Performs the preservation action./*from w w w . j a v a 2 s. c om*/ * * For Planets migration services url in {@link PreservationActionDefinition} carries the wsdl location of the migration service. */ public boolean perform(PreservationActionDefinition action, SampleObject sampleObject) throws PlatoServiceException { URL wsdlLocation; try { wsdlLocation = new URL(action.getUrl()); } catch (MalformedURLException e1) { e1.printStackTrace(); return false; } Service service = null; try { service = Service.create(wsdlLocation, Migrate.QNAME); } catch (WebServiceException e) { throw new PlatoServiceException("Error creating web service.", e); } Migrate m = (Migrate) service.getPort(Migrate.class); // create digital object that contains our sample object DigitalObject dob = new DigitalObject.Builder(Content.byValue(sampleObject.getData().getData())) .title("data").build(); FormatRegistry formatRegistry = FormatRegistryFactory.getFormatRegistry(); // create Planets URI from extension URI sourceFormat = formatRegistry.createExtensionUri(sampleObject.getFormatInfo().getDefaultExtension()); URI targetFormat; try { targetFormat = new URI(action.getTargetFormat()); } catch (URISyntaxException e) { throw new PlatoServiceException("Error in target format.", e); } List<Parameter> serviceParams = getParameters(action.getParamByName("settings")); if (serviceParams.size() <= 0) { serviceParams = null; } // perform migration MigrateResult result = m.migrate(dob, sourceFormat, targetFormat, serviceParams); MigrationResult migrationResult = new MigrationResult(); migrationResult.setSuccessful((result != null) && (result.getDigitalObject() != null)); if (migrationResult.isSuccessful()) { migrationResult.setReport(String.format("Service %s successfully migrated object.", wsdlLocation)); } else { migrationResult.setReport(String.format( "Service %s failed migrating object. " + ((result == null) ? "" : result.getReport()), wsdlLocation)); lastResult = migrationResult; return true; } InputStream in = result.getDigitalObject().getContent().getInputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream(); byte[] b = new byte[1024]; try { while ((in.read(b)) != -1) { out.write(b); } } catch (IOException e) { throw new PlatoServiceException("Unable to read result data from service response.", e); } migrationResult.getMigratedObject().getData().setData(out.toByteArray()); String fullName = sampleObject.getFullname(); String ext; try { ext = formatRegistry.getFirstExtension(new URI(action.getTargetFormat())); } catch (URISyntaxException e) { ext = ""; } // if we find an extension, cut if off ... if (fullName.lastIndexOf('.') > 0) { fullName = fullName.substring(0, fullName.lastIndexOf('.')); } // ... so we can append the new one. if (!"".equals(ext)) { fullName += ("." + ext); } migrationResult.getMigratedObject().setFullname(fullName); lastResult = migrationResult; return true; }
From source file:com.moss.veracity.core.load.VtOperationFactory.java
public VtOperationFactory(String identity, String password, URL baseUrl) throws Exception { log = LogFactory.getLog(this.getClass()); if (log.isDebugEnabled()) { log.debug("Materializing authentication service"); }/*from w ww. ja v a 2 s . co m*/ auth = Service.create( new URL("http://" + baseUrl.getHost() + ":" + baseUrl.getPort() + "/AuthenticationImpl?wsdl"), Authentication.QNAME).getPort(Authentication.class); if (log.isDebugEnabled()) { log.debug("Materializing management service"); } manage = Service .create(new URL("http://" + baseUrl.getHost() + ":" + baseUrl.getPort() + "/ManagementImpl?wsdl"), Management.QNAME) .getPort(Management.class); adminName = identity; universalToken = new VtPassword(password); if (log.isDebugEnabled()) { log.debug("Populating the veracity service with accounts for testing (100)"); } accounts = new ArrayList<VtAccount>(); final byte[] profileImage = loadResource("com/moss/veracity/core/root.jpg"); for (int i = 0; i < 100; i++) { VtImage image = new VtImage(); image.setData(profileImage); VtProfile profile = new VtProfile(); profile.setName(new StFirstMiddleLastName("Wannado", "F", "Mercer")); profile.setImage(image); profile.setProfileName("default"); profile.setWhenLastModified(System.currentTimeMillis()); VtAccount account = new VtAccount(); account.setName(UUID.randomUUID() + "@localhost"); account.setAuthMode(VtAuthMode.USER); account.getMechanisms().add(new VtPasswordMechanism(password)); account.getProfiles().add(profile); accounts.add(account); manage.create(account, adminEndorsement()); } random = new Random(System.currentTimeMillis()); }
From source file:mitm.common.ws.AbstractWSProxyFactory.java
private T internalCreateProxy() { QName SERVICE_NAME = new QName(nsURI, localPart); Service service = Service.create(wsdlURL, SERVICE_NAME); T proxy = service.getPort(persistentClass); /*// w w w . j a v a 2s . c o m * Make request context multithread safe. See http://markmail.org/message/lgldei2zt4trlyr6 */ ((BindingProvider) proxy).getRequestContext().put("thread.local.request.context", Boolean.TRUE); Client client = ClientProxy.getClient(proxy); HTTPConduit http = (HTTPConduit) client.getConduit(); HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setConnectionTimeout(connectTimeOut); httpClientPolicy.setReceiveTimeout(receiveTimeOut); http.setClient(httpClientPolicy); Endpoint endpoint = client.getEndpoint(); Map<String, Object> outProps = new HashMap<String, Object>(); outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN); outProps.put(WSHandlerConstants.PASSWORD_TYPE, passwordMode.getMode()); WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps); endpoint.getOutInterceptors().add(wssOut); return proxy; }
From source file:com.moss.rpcutil.proxy.jaxws.JAXWSProxyProvider.java
public synchronized <T> T getProxy(Class<T> iface, String url) { QName type = registry.get(iface); if (type == null) { throw new RuntimeException("Service type not registered: " + iface); }// w ww . ja va 2s .c o m T proxy = (T) cache.get(url); if (proxy == null) { Service service; try { String wsdlLocation = url; if (!wsdlLocation.endsWith("?wsdl")) { wsdlLocation += "?wsdl"; } service = Service.create(new URL(wsdlLocation), type); } catch (Exception ex) { throw new RuntimeException(ex); } if (log.isDebugEnabled()) { // SOAP LOGGING STUFF service.setHandlerResolver(new HandlerResolver() { public List<Handler> getHandlerChain(PortInfo arg0) { List<Handler> handlers = new LinkedList<Handler>(); handlers.add(new SOAPLoggingHandler(log)); return handlers; } }); } proxy = service.getPort(iface); // BindingProvider bp = (BindingProvider) proxy; // // bp.getRequestContext().put( // MessageContext.HTTP_REQUEST_HEADERS, // Collections.singletonMap("Content-Type", Arrays.asList(new String[]{"application/soap+xml", "charset=utf-8"})) // ); cache.put(url, proxy); } return proxy; }
From source file:eu.planets_project.tb.impl.services.mockups.workflow.ViewerWorkflow.java
public void setParameters(HashMap<String, String> parameters) throws Exception { this.parameters = parameters; // Attempt to connect to the Identify service. serviceEndpoint = new URL(this.parameters.get(PARAM_SERVICE)); service = Service.create(serviceEndpoint, CreateView.QNAME); viewMaker = service.getPort(CreateView.class); }
From source file:eu.planets_project.tb.gui.backing.exp.view.EmulationInspector.java
/** */ private void initViewResultBean() { if (this.experiment == null) return;/*from w w w .ja v a 2s .c o m*/ if (this.sessionId == null || "".equals(this.sessionId)) { return; } // Look up this session id in the experiment: List<ExecutionRecordImpl> executionRecords = new ArrayList<ExecutionRecordImpl>(); for (BatchExecutionRecordImpl batch : experiment.getExperimentExecutable().getBatchExecutionRecords()) { for (ExecutionRecordImpl run : batch.getRuns()) { executionRecords.add(run); } } List<ViewResultBean> vrbs = ViewResultBean.createResultsFromExecutionRecords(executionRecords); // Look for a match: for (ViewResultBean vrb : vrbs) { if (this.sessionId.equals(vrb.getSessionId())) { this.vrb = vrb; } } // Also fire up the connection to the service: try { Service serv = Service.create(vrb.getEndpoint(), CreateView.QNAME); this.viewService = serv.getPort(CreateView.class); } catch (Exception e) { e.printStackTrace(); } }