List of usage examples for javax.xml.ws BindingProvider getRequestContext
Map<String, Object> getRequestContext();
From source file:be.e_contract.mycarenet.consent.ConsentClient.java
@SuppressWarnings("unchecked") private void configureBindingProvider(BindingProvider bindingProvider, String location) { bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location); Binding binding = bindingProvider.getBinding(); @SuppressWarnings("rawtypes") List handlerChain = binding.getHandlerChain(); handlerChain.add(this.wsSecuritySOAPHandler); binding.setHandlerChain(handlerChain); }
From source file:com.nttdata.depend.util.OAuthUtil.java
public void reconfigureBindingProvider(BindingProvider bindingProvider) { String defaultEndpointURL = (String) bindingProvider.getRequestContext() .get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY); String actualEndpointURL = getInstanceURL() + defaultEndpointURL.substring(defaultEndpointURL.indexOf(URL_PATTERN)); bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, actualEndpointURL); }
From source file:be.e_contract.mycarenet.xkms.XKMSClient.java
/** * Main constructor.//from w w w. j a v a 2 s .co m * * @param location * the URL of the MyCareNet XKMS web service. */ public XKMSClient(String location) { XMLKeyManagementService service = XKMSServiceFactory.newInstance(); this.port = service.getKeyServiceSoapPort(); BindingProvider bindingProvider = (BindingProvider) this.port; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location); Binding binding = bindingProvider.getBinding(); @SuppressWarnings("rawtypes") List<Handler> handlerChain = binding.getHandlerChain(); handlerChain.add(new LoggingHandler()); this.proofOfPossessionSignatureSOAPHandler = new ProofOfPossessionSignatureSOAPHandler(); handlerChain.add(this.proofOfPossessionSignatureSOAPHandler); handlerChain.add(new LoggingHandler()); binding.setHandlerChain(handlerChain); this.objectFactory = new ObjectFactory(); this.xmldsigObjectFactory = new be.e_contract.mycarenet.jaxb.xmldsig.ObjectFactory(); }
From source file:ebay.dts.client.FileTransferCall.java
public FileTransferServicePort setFTSMessageContext(String callName) throws EbayConnectorException { logger.trace("FileTransferActions.setFTSMessageContext(String callName ) ...... "); FileTransferServicePort port = null; FileTransferService service = new FileTransferService(); port = service.getFileTransferServiceSOAP(); BindingProvider bp = (BindingProvider) port; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serverURL); List handlerList = bp.getBinding().getHandlerChain(); if (handlerList == null) { handlerList = new ArrayList(); }// www. jav a2 s . c om LoggingHandler loggingHandler = new LoggingHandler(); handlerList.add(loggingHandler); // register the handerList bp.getBinding().setHandlerChain(handlerList); // initialize WS operation arguments here Map requestProperties = bp.getRequestContext(); // set http address logger.trace("serverURL :" + this.serverURL); if (this.serverURL == null) { throw new EbayConnectorException(" serverURL can't be null "); } if (this.userToken == null) { throw new EbayConnectorException(" User Token can't be null "); } requestProperties.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serverURL); Map<String, List<String>> httpHeaders = new HashMap<String, List<String>>(); httpHeaders.put("X-EBAY-SOA-MESSAGE-PROTOCOL", Collections.singletonList("SOAP12")); httpHeaders.put("X-EBAY-SOA-OPERATION-NAME", Collections.singletonList(callName)); httpHeaders.put("X-EBAY-SOA-SECURITY-TOKEN", Collections.singletonList(this.userToken)); requestProperties.put(MessageContext.HTTP_REQUEST_HEADERS, httpHeaders); return port; }
From source file:ebay.dts.client.FileTransferCall.java
public FileTransferServicePort setFTSMessageContext() throws EbayConnectorException { FileTransferServicePort port = null; FileTransferService service = new FileTransferService(); try {/*from w w w. ja v a2 s .c o m*/ port = service.getFileTransferServiceSOAP(); BindingProvider bp = (BindingProvider) port; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, this.serverURL); List handlerList = bp.getBinding().getHandlerChain(); if (handlerList == null) { handlerList = new ArrayList(); } LoggingHandler loggingHandler = new LoggingHandler(); handlerList.add(loggingHandler); // register the handerList bp.getBinding().setHandlerChain(handlerList); // initialize WS operation arguments here Map requestProperties = bp.getRequestContext(); // set http address if (this.serverURL == null) { throw new Exception(" serverURL can't be null "); } int timeout = 100; requestProperties.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serverURL); requestProperties.put(JAXWSProperties.CONNECT_TIMEOUT, timeout); Map<String, List<String>> httpHeaders = new HashMap<String, List<String>>(); httpHeaders.put("X-EBAY-SOA-MESSAGE-PROTOCOL", Collections.singletonList("SOAP12")); httpHeaders.put("X-EBAY-SOA-OPERATION-NAME", Collections.singletonList(this.callName)); httpHeaders.put("X-EBAY-SOA-SECURITY-TOKEN", Collections.singletonList(this.userToken)); requestProperties.put(MessageContext.HTTP_REQUEST_HEADERS, httpHeaders); } catch (Exception e) { throw new EbayConnectorException("Errore nel setup uplink: " + e.getMessage(), e); } return port; }
From source file:at.tfr.securefs.client.SecurefsFileServiceClient.java
public void run() { DateTime start = new DateTime(); try {/* w w w . ja v a 2s .co m*/ FileService svc = new FileService(new URL(fileServiceUrl)); BindingProvider binding = (BindingProvider) svc.getFileServicePort(); binding.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username); binding.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password); for (Path path : files) { if (write) { if (!path.toFile().exists()) { System.err.println(Thread.currentThread() + ": NoSuchFile: " + path + " currentWorkdir=" + Paths.get("./").toAbsolutePath()); continue; } System.out.println(Thread.currentThread() + ": Sending file: " + start + " : " + path); svc.getFileServicePort().write(path.toString(), IOUtils.toByteArray(Files.newInputStream(path))); } Path out = path.resolveSibling( path.getFileName() + (asyncTest ? "." + Thread.currentThread().getId() : "") + ".out"); if (read) { System.out.println(Thread.currentThread() + ": Reading file: " + new DateTime() + " : " + out); if (out.getParent() != null) { Files.createDirectories(out.getParent()); } byte[] arr = svc.getFileServicePort().read(path.toString()); IOUtils.write(arr, Files.newOutputStream(out)); } if (write && read) { long inputChk = FileUtils.checksumCRC32(path.toFile()); long outputChk = FileUtils.checksumCRC32(out.toFile()); if (inputChk != outputChk) { throw new IOException(Thread.currentThread() + ": Checksum Failed: failure to write/read: in=" + path + ", out=" + out); } System.out.println(Thread.currentThread() + ": Checked Checksums: " + new DateTime() + " : " + inputChk + " / " + outputChk); } if (delete) { boolean deleted = svc.getFileServicePort().delete(path.toString()); if (!deleted) { throw new IOException( Thread.currentThread() + ": Delete Failed: failure to delete: in=" + path); } else { System.out.println(Thread.currentThread() + ": Deleted File: in=" + path); } } } } catch (Throwable t) { t.printStackTrace(); throw new RuntimeException(t); } }
From source file:be.e_contract.mycarenet.ehbox.EHealthBoxPublicationClient.java
@SuppressWarnings("unchecked") private void configureBindingProvider(BindingProvider bindingProvider, String location) { bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location); Binding binding = bindingProvider.getBinding(); @SuppressWarnings("rawtypes") List handlerChain = binding.getHandlerChain(); handlerChain.add(this.wsSecuritySOAPHandler); handlerChain.add(new LoggingHandler()); handlerChain.add(this.payloadLogicalHandler); binding.setHandlerChain(handlerChain); }
From source file:be.fedict.eid.idp.sp.protocol.ws_federation.sts.SecurityTokenServiceClient.java
/** * Main constructor.//w ww . ja v a 2 s. co m * * @param location * the location of the STS service. */ public SecurityTokenServiceClient(String location) { SecurityTokenService securityTokenService = SecurityTokenServiceFactory.getInstance(); this.port = securityTokenService.getSecurityTokenServicePort(); BindingProvider bindingProvider = (BindingProvider) this.port; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location); Binding binding = bindingProvider.getBinding(); List<Handler> handlerChain = binding.getHandlerChain(); handlerChain.add(new WSSecuritySoapHandler()); handlerChain.add(new LoggingSoapHandler()); binding.setHandlerChain(handlerChain); this.objectFactory = new ObjectFactory(); this.policyObjectFactory = new be.fedict.eid.idp.wstrust.jaxb.wspolicy.ObjectFactory(); this.addrObjectFactory = new be.fedict.eid.idp.wstrust.jaxb.wsaddr.ObjectFactory(); this.wsseObjectFactory = new be.fedict.eid.idp.wstrust.jaxb.wsse.ObjectFactory(); }
From source file:be.e_contract.mycarenet.certra.CertRAClient.java
public CertRAClient(String location) { CertRaService certRaService = CertRaServiceFactory.newInstance(); this.port = certRaService.getCertRaPort(); BindingProvider bindingProvider = (BindingProvider) this.port; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location); Binding binding = bindingProvider.getBinding(); List<Handler> handlerChain = binding.getHandlerChain(); handlerChain.add(new LoggingHandler()); // LoggingHandler makes CXF fail on the attachments. // https://issues.apache.org/jira/browse/CXF-5496 binding.setHandlerChain(handlerChain); this.protocolObjectFactory = new be.e_contract.mycarenet.certra.jaxb.protocol.ObjectFactory(); }
From source file:com.evolveum.midpoint.infra.wsutil.AbstractWebServiceClient.java
protected P createPort() throws Exception { String password = getDefaultPassword(); String username = getDefaultUsername(); String endpointUrl = getDefaultEndpointUrl(); if (commandLine.hasOption('p')) { password = commandLine.getOptionValue('p'); }/*from w ww . ja v a2 s . co m*/ if (commandLine.hasOption('u')) { username = commandLine.getOptionValue('u'); } if (commandLine.hasOption('e')) { endpointUrl = commandLine.getOptionValue('e'); } if (verbose) { System.out.println("Username: " + username); System.out.println("Password: <not shown>"); System.out.println("Endpoint URL: " + endpointUrl); } // uncomment this if you want to use Fiddler or any other proxy //ProxySelector.setDefault(new MyProxySelector("127.0.0.1", 8888)); P modelPort = createService().getPort(getPortClass()); BindingProvider bp = (BindingProvider) modelPort; Map<String, Object> requestContext = bp.getRequestContext(); requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointUrl); org.apache.cxf.endpoint.Client client = ClientProxy.getClient(modelPort); org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint(); Map<String, Object> wssProps = new HashMap<String, Object>(); if (!commandLine.hasOption('a') || (commandLine.hasOption('a') && WSHandlerConstants.USERNAME_TOKEN.equals(commandLine.getOptionValue('a')))) { wssProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN); wssProps.put(WSHandlerConstants.USER, username); wssProps.put(WSHandlerConstants.PASSWORD_TYPE, getPasswordType()); wssProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordHandler.class.getName()); ClientPasswordHandler.setPassword(password); WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(wssProps); cxfEndpoint.getOutInterceptors().add(wssOut); } else if (commandLine.hasOption('a') && "none".equals(commandLine.getOptionValue('a'))) { // Nothing to do } else { throw new IllegalArgumentException( "Unknown authentication mechanism '" + commandLine.getOptionValue('a') + "'"); } if (commandLine.hasOption('m')) { cxfEndpoint.getInInterceptors().add(new LoggingInInterceptor()); cxfEndpoint.getOutInterceptors().add(new LoggingOutInterceptor()); } return modelPort; }