use of javax.xml.ws.BindingProvider in project midpoint by Evolveum.
the class Action method createModelPort.
protected ModelPortType createModelPort() {
ModelService modelService = new ModelService();
ModelPortType port = modelService.getModelPort();
BindingProvider bp = (BindingProvider) port;
Client client = ClientProxy.getClient(port);
Endpoint endpoint = client.getEndpoint();
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = http.getClient();
if (httpClientPolicy == null) {
httpClientPolicy = new HTTPClientPolicy();
http.setClient(httpClientPolicy);
}
httpClientPolicy.setConnectionTimeout(10000);
Map<String, Object> requestContext = bp.getRequestContext();
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, params.getUrl().toString());
requestContext.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
requestContext.put(WSHandlerConstants.USER, params.getUsername());
requestContext.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST);
ClientPasswordHandler handler = new ClientPasswordHandler();
handler.setPassword(params.getInsertedPassword());
requestContext.put(WSHandlerConstants.PW_CALLBACK_REF, handler);
WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(requestContext);
endpoint.getOutInterceptors().add(wssOut);
if (params.isVerbose()) {
endpoint.getOutInterceptors().add(new LoggingOutInterceptor());
endpoint.getInInterceptors().add(new LoggingInInterceptor());
}
return port;
}
use of javax.xml.ws.BindingProvider in project nhin-d by DirectProject.
the class DocumentRepositoryProxy method initProxy.
private void initProxy() {
try {
URL url = DocumentRepositoryProxy.class.getClassLoader().getResource("XDS.b_DocumentRepositoryWSDLSynchMTOM.wsdl");
QName qname = new QName("urn:ihe:iti:xds-b:2007", "DocumentRepository_Service");
DocumentRepositoryService service = new DocumentRepositoryService(url, qname);
if (handlerResolver != null)
service.setHandlerResolver(handlerResolver);
proxy = service.getDocumentRepositoryPortSoap12(new MTOMFeature(true, 1));
BindingProvider bp = (BindingProvider) proxy;
SOAPBinding binding = (SOAPBinding) bp.getBinding();
binding.setMTOMEnabled(true);
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint);
} catch (Exception e) {
LOGGER.error("Error initializing proxy.", e);
}
}
use of javax.xml.ws.BindingProvider in project tdi-studio-se by Talend.
the class NetsuiteManagement_CXF method initializeStub.
public void initializeStub() throws Exception {
URL wsdl_locationUrl = this.getClass().getResource("/wsdl/netsuite.wsdl");
QName serviceQname = new QName("urn:platform_2014_2.webservices.netsuite.com", "NetSuiteService");
NetSuiteService service = new NetSuiteService(wsdl_locationUrl, serviceQname);
NetSuitePortType port = service.getNetSuitePort();
BindingProvider provider = (BindingProvider) port;
Map<String, Object> requestContext = provider.getRequestContext();
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, _url);
Preferences preferences = new Preferences();
preferences.setDisableMandatoryCustomFieldValidation(Boolean.FALSE);
preferences.setWarningAsError(Boolean.FALSE);
preferences.setIgnoreReadOnlyFields(Boolean.TRUE);
preferences.setDisableMandatoryCustomFieldValidation(Boolean.TRUE);
SearchPreferences searchPreferences = new SearchPreferences();
searchPreferences.setPageSize(this._pageSize);
searchPreferences.setBodyFieldsOnly(Boolean.valueOf(false));
RecordRef role = new RecordRef();
role.setInternalId(this._role);
Passport passport = new Passport();
passport.setEmail(this._email);
passport.setPassword(this._pwd);
passport.setRole(role);
passport.setAccount(this._account);
// Get the webservices domain for your account
GetDataCenterUrlsRequest dataCenterRequest = new GetDataCenterUrlsRequest();
dataCenterRequest.setAccount(this._account);
DataCenterUrls urls = null;
GetDataCenterUrlsResponse reponse = port.getDataCenterUrls(dataCenterRequest);
if (reponse != null && reponse.getGetDataCenterUrlsResult() != null) {
urls = reponse.getGetDataCenterUrlsResult().getDataCenterUrls();
}
if (urls == null) {
throw new Exception("Can't get a correct webservice domain! Please check your configuration or try to run again.");
}
String wsDomain = urls.getWebservicesDomain();
String endpoint = wsDomain.concat(new URL(this._url).getPath());
requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint);
List<Header> list = (List<Header>) requestContext.get(Header.HEADER_LIST);
if (list == null) {
list = new ArrayList<Header>();
requestContext.put(Header.HEADER_LIST, list);
}
Header searchPreferences_header = new Header(new QName("urn:messages_2014_2.platform.webservices.netsuite.com", "searchPreferences"), searchPreferences, new JAXBDataBinding(searchPreferences.getClass()));
Header preferences_header = new Header(new QName("urn:messages_2014_2.platform.webservices.netsuite.com", "preferences"), preferences, new JAXBDataBinding(preferences.getClass()));
list.add(searchPreferences_header);
list.add(preferences_header);
LoginRequest request = new LoginRequest();
request.setPassport(passport);
port.login(request);
this._port = port;
Arrays.asList(new String[] { "", "", "" });
}
use of javax.xml.ws.BindingProvider in project ats-framework by Axway.
the class AgentServicePool method createServicePort.
private AgentService createServicePort(String host) throws AgentException {
try {
String protocol = AgentConfigurator.getConnectionProtocol(host);
if (protocol == null) {
protocol = "http";
} else {
SslUtils.trustAllHttpsCertificates();
SslUtils.trustAllHostnames();
}
URL url = this.getClass().getResource("/META-INF/wsdl/" + AgentWsDefinitions.AGENT_SERVICE_XML_LOCAL_NAME + ".wsdl");
Service agentService = Service.create(url, new QName(AgentWsDefinitions.AGENT_SERVICE_XML_TARGET_NAMESPACE, AgentWsDefinitions.AGENT_SERVICE_XML_LOCAL_NAME));
AgentService agentServicePort = agentService.getPort(new QName(AgentWsDefinitions.AGENT_SERVICE_XML_TARGET_NAMESPACE, AgentWsDefinitions.AGENT_SERVICE_XML_PORT_NAME), AgentService.class);
Map<String, Object> ctxt = ((BindingProvider) agentServicePort).getRequestContext();
// setting ENDPOINT ADDRESS, which defines the web service URL for SOAP communication
// NOTE: if we specify WSDL URL (...<endpoint_address>?wsdl), the JBoss server returns the WSDL on a SOAP call,
// but we are expecting a SOAP message response and an exception is thrown.
// The Jetty server (in ATS agents) is working in both cases.
ctxt.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, protocol + "://" + host + AgentWsDefinitions.AGENT_SERVICE_ENDPOINT_ADDRESS);
// setting timeouts
// timeout in milliseconds
ctxt.put(BindingProviderProperties.CONNECT_TIMEOUT, 10000);
// check if new unique id must be generated each time
if (!useNewUuId) {
// create temp file containing caller working directory and the unique id
String userWorkingDirectory = AtsSystemProperties.SYSTEM_USER_HOME_DIR;
String uuiFileLocation = AtsSystemProperties.SYSTEM_USER_TEMP_DIR + AtsSystemProperties.SYSTEM_FILE_SEPARATOR + "\\ats_uid.txt";
File uuiFile = new File(uuiFileLocation);
// otherwise add it to the file
if (uuiFile.exists()) {
String uuiFileContent = IoUtils.streamToString(IoUtils.readFile(uuiFileLocation));
if (uuiFileContent.contains(userWorkingDirectory)) {
for (String line : uuiFileContent.split("\n")) {
if (line.contains(userWorkingDirectory)) {
uniqueId = line.substring(userWorkingDirectory.length()).trim();
}
}
} else {
generateNewUUID();
new LocalFileSystemOperations().appendToFile(uuiFileLocation, userWorkingDirectory + "\t" + uniqueId + "\n");
}
} else {
generateNewUUID();
try {
uuiFile.createNewFile();
} catch (IOException e) {
log.warn("Unable to create file '" + uuiFile.getAbsolutePath() + "'");
}
if (uuiFile.exists()) {
new LocalFileSystemOperations().appendToFile(uuiFileLocation, userWorkingDirectory + "\t" + uniqueId + "\n");
}
}
} else {
generateNewUUID();
}
// add header with unique session ID
Map<String, List<String>> requestHeaders = new HashMap<>();
requestHeaders.put(ApplicationContext.ATS_UID_SESSION_TOKEN, Arrays.asList(uniqueId));
ctxt.put(MessageContext.HTTP_REQUEST_HEADERS, requestHeaders);
return agentServicePort;
} catch (Exception e) {
throw new AgentException("Cannot connect to Agent application on host '" + host + "' check your configuration", e);
}
}
use of javax.xml.ws.BindingProvider in project cloudstack by apache.
the class VmwareClient method connect.
/**
* Establishes session with the virtual center server.
*
* @throws Exception
* the exception
*/
public void connect(String url, String userName, String password) throws Exception {
svcInstRef.setType(SVC_INST_NAME);
svcInstRef.setValue(SVC_INST_NAME);
vimPort = vimService.getVimPort();
Map<String, Object> ctxt = ((BindingProvider) vimPort).getRequestContext();
ctxt.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
ctxt.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
ctxt.put("com.sun.xml.internal.ws.request.timeout", vCenterSessionTimeout);
ctxt.put("com.sun.xml.internal.ws.connect.timeout", vCenterSessionTimeout);
ServiceContent serviceContent = vimPort.retrieveServiceContent(svcInstRef);
// Extract a cookie. See vmware sample program com.vmware.httpfileaccess.GetVMFiles
@SuppressWarnings("unchecked") Map<String, List<String>> headers = (Map<String, List<String>>) ((BindingProvider) vimPort).getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
List<String> cookies = headers.get("Set-cookie");
vimPort.login(serviceContent.getSessionManager(), userName, password, null);
if (cookies == null) {
// Get the cookie from the response header. See vmware sample program com.vmware.httpfileaccess.GetVMFiles
@SuppressWarnings("unchecked") Map<String, List<String>> responseHeaders = (Map<String, List<String>>) ((BindingProvider) vimPort).getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
cookies = responseHeaders.get("Set-cookie");
if (cookies == null) {
String msg = "Login successful, but failed to get server cookies from url :[" + url + "]";
s_logger.error(msg);
throw new Exception(msg);
}
}
String cookieValue = cookies.get(0);
StringTokenizer tokenizer = new StringTokenizer(cookieValue, ";");
cookieValue = tokenizer.nextToken();
String pathData = "$" + tokenizer.nextToken();
serviceCookie = "$Version=\"1\"; " + cookieValue + "; " + pathData;
isConnected = true;
}
Aggregations