List of usage examples for javax.xml.ws BindingProvider ENDPOINT_ADDRESS_PROPERTY
String ENDPOINT_ADDRESS_PROPERTY
To view the source code for javax.xml.ws BindingProvider ENDPOINT_ADDRESS_PROPERTY.
Click Source Link
From source file:com.tremolosecurity.provisioning.sharepoint.SharePointGroups.java
private UserGroupSoap getConnection(URL url) throws Exception { UserGroup ss = new UserGroup(wsdl.toURI().toURL(), SERVICE); UserGroupSoap port = ss.getUserGroupSoap12(); BindingProvider provider = (BindingProvider) port; if (authType == AuthType.UnisonLastMile) { DateTime now = new DateTime(); DateTime future = now.plusMillis(this.skew); now = now.minusMillis(skew);//from w ww . jav a 2 s . c o m com.tremolosecurity.lastmile.LastMile lastmile = new com.tremolosecurity.lastmile.LastMile( url.getPath(), now, future, 0, "chainName"); lastmile.getAttributes().add(new Attribute("userPrincipalName", this.administratorUPN)); SecretKey sk = this.cfg.getSecretKey(this.keyAlias); Map<String, List<String>> headers = (Map<String, List<String>>) provider.getRequestContext() .get(MessageContext.HTTP_REQUEST_HEADERS); if (headers == null) { headers = new HashMap<String, List<String>>(); } headers.put(this.headerName, Collections.singletonList(lastmile.generateLastMileToken(sk))); provider.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, headers); } else if (authType == AuthType.NTLM) { NtlmAuthenticator authenticator = new NtlmAuthenticator(this.administratorUPN, this.administratorPassword); Authenticator.setDefault(authenticator); } provider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url.toString()); return port; }
From source file:com.mirth.connect.connectors.ws.WebServiceDispatcher.java
@Override public Response send(ConnectorProperties connectorProperties, ConnectorMessage connectorMessage) { WebServiceDispatcherProperties webServiceDispatcherProperties = (WebServiceDispatcherProperties) connectorProperties; eventController.dispatchEvent(new ConnectionStatusEvent(getChannelId(), getMetaDataId(), getDestinationName(), ConnectionStatusEventType.SENDING)); String responseData = null;/* ww w . j av a 2 s .c o m*/ String responseError = null; String responseStatusMessage = null; Status responseStatus = Status.QUEUED; boolean validateResponse = false; try { long dispatcherId = getDispatcherId(); DispatchContainer dispatchContainer = dispatchContainers.get(dispatcherId); if (dispatchContainer == null) { dispatchContainer = new DispatchContainer(); dispatchContainers.put(dispatcherId, dispatchContainer); } /* * Initialize the dispatch object if it hasn't been initialized yet, or create a new one * if the connector properties have changed due to variables. */ createDispatch(webServiceDispatcherProperties, dispatchContainer); Dispatch<SOAPMessage> dispatch = dispatchContainer.getDispatch(); configuration.configureDispatcher(this, webServiceDispatcherProperties, dispatch.getRequestContext()); SOAPBinding soapBinding = (SOAPBinding) dispatch.getBinding(); if (webServiceDispatcherProperties.isUseAuthentication()) { String currentUsername = dispatchContainer.getCurrentUsername(); String currentPassword = dispatchContainer.getCurrentPassword(); dispatch.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, currentUsername); dispatch.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, currentPassword); logger.debug("Using authentication: username=" + currentUsername + ", password length=" + currentPassword.length()); } // See: http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383528 String soapAction = webServiceDispatcherProperties.getSoapAction(); if (StringUtils.isNotEmpty(soapAction)) { dispatch.getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, true); // MIRTH-2109 dispatch.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, soapAction); } // Get default headers Map<String, List<String>> requestHeaders = new HashMap<String, List<String>>( dispatchContainer.getDefaultRequestHeaders()); // Add custom headers if (MapUtils.isNotEmpty(webServiceDispatcherProperties.getHeaders())) { for (Entry<String, List<String>> entry : webServiceDispatcherProperties.getHeaders().entrySet()) { List<String> valueList = requestHeaders.get(entry.getKey()); if (valueList == null) { valueList = new ArrayList<String>(); requestHeaders.put(entry.getKey(), valueList); } valueList.addAll(entry.getValue()); } } dispatch.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, requestHeaders); // build the message logger.debug("Creating SOAP envelope."); AttachmentHandlerProvider attachmentHandlerProvider = getAttachmentHandlerProvider(); String content = attachmentHandlerProvider.reAttachMessage(webServiceDispatcherProperties.getEnvelope(), connectorMessage); Source source = new StreamSource(new StringReader(content)); SOAPMessage message = soapBinding.getMessageFactory().createMessage(); message.getSOAPPart().setContent(source); if (webServiceDispatcherProperties.isUseMtom()) { soapBinding.setMTOMEnabled(true); List<String> attachmentIds = webServiceDispatcherProperties.getAttachmentNames(); List<String> attachmentContents = webServiceDispatcherProperties.getAttachmentContents(); List<String> attachmentTypes = webServiceDispatcherProperties.getAttachmentTypes(); for (int i = 0; i < attachmentIds.size(); i++) { String attachmentContentId = attachmentIds.get(i); String attachmentContentType = attachmentTypes.get(i); String attachmentContent = attachmentHandlerProvider.reAttachMessage(attachmentContents.get(i), connectorMessage); AttachmentPart attachment = message.createAttachmentPart(); attachment.setBase64Content(new ByteArrayInputStream(attachmentContent.getBytes("UTF-8")), attachmentContentType); attachment.setContentId(attachmentContentId); message.addAttachmentPart(attachment); } } message.saveChanges(); if (StringUtils.isNotBlank(webServiceDispatcherProperties.getLocationURI())) { dispatch.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, webServiceDispatcherProperties.getLocationURI()); } boolean redirect = false; int tryCount = 0; /* * Attempt the invocation until we hit the maximum allowed redirects. The redirections * we handle are when the scheme changes (i.e. from HTTP to HTTPS). */ do { redirect = false; tryCount++; try { DispatchTask<SOAPMessage> task = new DispatchTask<SOAPMessage>(dispatch, message, webServiceDispatcherProperties.isOneWay()); SOAPMessage result; /* * If the timeout is set to zero, we need to do the invocation in a separate * thread. This is because there's no way to get a reference to the underlying * JAX-WS socket, so there's no way to forcefully halt the dispatch. If the * socket is truly hung and the user halts the channel, the best we can do is * just interrupt and ignore the thread. This means that a thread leak is * potentially introduced, so we need to notify the user appropriately. */ if (timeout == 0) { // Submit the task to an executor so that it's interruptible Future<SOAPMessage> future = executor.submit(task); // Keep track of the task by adding it to our set dispatchTasks.add(task); result = future.get(); } else { // Call the task directly result = task.call(); } if (webServiceDispatcherProperties.isOneWay()) { responseStatusMessage = "Invoked one way operation successfully."; } else { responseData = sourceToXmlString(result.getSOAPPart().getContent()); responseStatusMessage = "Invoked two way operation successfully."; } logger.debug("Finished invoking web service, got result."); // Automatically accept message; leave it up to the response transformer to find SOAP faults responseStatus = Status.SENT; } catch (Throwable e) { // Unwrap the exception if it came from the executor if (e instanceof ExecutionException && e.getCause() != null) { e = e.getCause(); } // If the dispatch was interrupted, make sure to reset the interrupted flag if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); } Integer responseCode = null; String location = null; if (dispatch.getResponseContext() != null) { responseCode = (Integer) dispatch.getResponseContext() .get(MessageContext.HTTP_RESPONSE_CODE); Map<String, List<String>> headers = (Map<String, List<String>>) dispatch .getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS); if (MapUtils.isNotEmpty(headers)) { List<String> locations = headers.get("Location"); if (CollectionUtils.isNotEmpty(locations)) { location = locations.get(0); } } } if (tryCount < MAX_REDIRECTS && responseCode != null && responseCode >= 300 && responseCode < 400 && StringUtils.isNotBlank(location)) { redirect = true; // Replace the endpoint with the redirected URL dispatch.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location); } else { // Leave the response status as QUEUED for NoRouteToHostException and ConnectException, otherwise ERROR if (e instanceof NoRouteToHostException || ((e.getCause() != null) && (e.getCause() instanceof NoRouteToHostException))) { responseStatusMessage = ErrorMessageBuilder.buildErrorResponse("HTTP transport error", e); responseError = ErrorMessageBuilder.buildErrorMessage(connectorProperties.getName(), "HTTP transport error", e); eventController.dispatchEvent( new ErrorEvent(getChannelId(), getMetaDataId(), connectorMessage.getMessageId(), ErrorEventType.DESTINATION_CONNECTOR, getDestinationName(), connectorProperties.getName(), "HTTP transport error.", e)); } else if ((e.getClass() == ConnectException.class) || ((e.getCause() != null) && (e.getCause().getClass() == ConnectException.class))) { responseStatusMessage = ErrorMessageBuilder.buildErrorResponse("Connection refused.", e); eventController.dispatchEvent(new ErrorEvent(getChannelId(), getMetaDataId(), connectorMessage.getMessageId(), ErrorEventType.DESTINATION_CONNECTOR, getDestinationName(), connectorProperties.getName(), "Connection refused.", e)); } else { if (e instanceof SOAPFaultException) { try { responseData = new DonkeyElement(((SOAPFaultException) e).getFault()).toXml(); } catch (DonkeyElementException e2) { } } responseStatus = Status.ERROR; responseStatusMessage = ErrorMessageBuilder .buildErrorResponse("Error invoking web service", e); responseError = ErrorMessageBuilder.buildErrorMessage(connectorProperties.getName(), "Error invoking web service", e); eventController.dispatchEvent( new ErrorEvent(getChannelId(), getMetaDataId(), connectorMessage.getMessageId(), ErrorEventType.DESTINATION_CONNECTOR, getDestinationName(), connectorProperties.getName(), "Error invoking web service.", e)); } } } } while (redirect && tryCount < MAX_REDIRECTS); } catch (Exception e) { responseStatusMessage = ErrorMessageBuilder.buildErrorResponse("Error creating web service dispatch", e); responseError = ErrorMessageBuilder.buildErrorMessage(connectorProperties.getName(), "Error creating web service dispatch", e); eventController.dispatchEvent(new ErrorEvent(getChannelId(), getMetaDataId(), connectorMessage.getMessageId(), ErrorEventType.DESTINATION_CONNECTOR, getDestinationName(), connectorProperties.getName(), "Error creating web service dispatch.", e)); } finally { eventController.dispatchEvent(new ConnectionStatusEvent(getChannelId(), getMetaDataId(), getDestinationName(), ConnectionStatusEventType.IDLE)); } return new Response(responseStatus, responseData, responseStatusMessage, responseError, validateResponse); }
From source file:edu.ku.kuali.kra.award.sapintegration.SapIntegrationServiceImpl.java
/** * Configures the service endpoint by configuring basic http authentication * on the service as well as setting a custom value for the service endpoint * if one has been configured.//from w w w . ja v a 2 s.co m */ protected void configureServiceEndpoint(SIKCRMPROCESSOUTBOUND serviceEndpoint, PrintWriter sendWriter, PrintWriter receiveWriter) { Client client = ClientProxy.getClient(serviceEndpoint); client.getOutInterceptors().add(new LoggingOutInterceptor(sendWriter)); client.getInInterceptors().add(new LoggingInInterceptor(receiveWriter)); String connectionTimeout = ConfigContext.getCurrentContextConfig() .getProperty(SAP_SERVICE_CONNECTION_TIMEOUT_PARAM); String receiveTimeout = ConfigContext.getCurrentContextConfig() .getProperty(SAP_SERVICE_RECEIVE_TIMEOUT_PARAM); if (!StringUtils.isBlank(connectionTimeout) || !StringUtils.isBlank(receiveTimeout)) { Conduit conduit = client.getConduit(); if (conduit instanceof HTTPConduit) { HTTPConduit httpConduit = (HTTPConduit) conduit; HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); if (!StringUtils.isBlank(connectionTimeout)) { httpClientPolicy.setConnectionTimeout(Long.parseLong(connectionTimeout)); } if (!StringUtils.isBlank(receiveTimeout)) { httpClientPolicy.setReceiveTimeout(Long.parseLong(receiveTimeout)); } httpConduit.setClient(httpClientPolicy); } } if (!(serviceEndpoint instanceof BindingProvider)) { throw new IllegalArgumentException( "The given service endpoint should be an instance of BindingProvider but was not."); } BindingProvider provider = (BindingProvider) serviceEndpoint; Map<String, Object> requestContext = provider.getRequestContext(); String username = ConfigContext.getCurrentContextConfig().getProperty(SAP_SERVICE_USERNAME_PARAM); String password = ConfigContext.getCurrentContextConfig().getProperty(SAP_SERVICE_PASSWORD_PARAM); if (StringUtils.isBlank(username)) { throw new IllegalStateException( "No username was configured for the SAP service, please ensure that the following configuration parameter is set: " + SAP_SERVICE_USERNAME_PARAM); } if (StringUtils.isBlank(password)) { throw new IllegalStateException( "No passwrod was configured for the SAP service, please ensure that the following configuration parameter is set: " + SAP_SERVICE_PASSWORD_PARAM); } requestContext.put(BindingProvider.USERNAME_PROPERTY, username); requestContext.put(BindingProvider.PASSWORD_PROPERTY, password); // next check if a custom endpoint url has been configured String endpointUrl = ConfigContext.getCurrentContextConfig().getProperty(SAP_SERVICE_URL_PARAM); if (!StringUtils.isBlank(endpointUrl)) { requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointUrl); } }
From source file:gov.va.ds4p.ds4pmobileportal.ui.eHealthExchange.java
private void getDocument() { String sOrg = AdminContext.getSessionAttributes().getSelectedOrg(); if (sOrg.equals("FEISystems")) { RetrieveDocumentSetRequest request = new RetrieveDocumentSetRequest(); AdminContext.getSessionAttributes().setServiceName("DocumentRetrieve"); setSAMLValues();//from ww w.jav a2s. com request.setDocumentUniqueId(docId); request.setMessageId(messageId); request.setIntendedRecipient(AdminContext.getSessionAttributes().getProviderId()); WebServiceFeature features = new AddressingFeature(true); SecuredFilterC32Service service = new SecuredFilterC32Service(); SecuredFilterC32ServicePortType port = service.getSecuredFilterC32Port(features); ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, AdminContext.getSessionAttributes().getSelectedXDSRep()); RetrieveDocumentSetResponse response = port.retrieveDocumentSet(request); currentDocument = response.getReturn(); metaData = response.getMetadata(); keyD = response.getKekEncryptionKey(); keyM = response.getKekMaskingKey(); } else { XDSRepositorybWebServiceClient gWeb = new XDSRepositorybWebServiceClient( AdminContext.getSessionAttributes().getSelectedXDSRep()); ihe.iti.xds_b._2007.RetrieveDocumentSetRequest request = new ihe.iti.xds_b._2007.RetrieveDocumentSetRequest(); ihe.iti.xds_b._2007.RetrieveDocumentSetRequest.DocumentRequest docRequest = new ihe.iti.xds_b._2007.RetrieveDocumentSetRequest.DocumentRequest(); docRequest.setRepositoryUniqueId("1.3.6.1.4.1.21367.2010.1.2.1040"); docRequest.setHomeCommunityId(AdminContext.getSessionAttributes().getSelectedOrgId()); docRequest.setDocumentUniqueId(docId); request.getDocumentRequest().add(docRequest); ihe.iti.xds_b._2007.RetrieveDocumentSetResponse resp = gWeb.retrieveDocumentSetRequest(request); ihe.iti.xds_b._2007.RetrieveDocumentSetResponse.DocumentResponse docResp = resp.getDocumentResponse() .get(0); currentDocument = new String(docResp.getDocument()); } }
From source file:gov.va.ds4p.ds4pmobileportal.pep.XACMLPolicyEnforcement.java
private void logEvent(AuthLog authlog) { try {/*www. ja v a 2 s . c o m*/ DS4PAuditService service = new DS4PAuditService(); DS4PAudit port = service.getDS4PAuditPort(); ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, auditEndpoint); port.saveAuthorizationEvent(authlog); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:gov.va.ds4p.ds4pmobileportal.ui.eHealthExchange.java
private String lookUpPatient() { String res = ""; String sOrg = AdminContext.getSessionAttributes().getSelectedOrg(); if (sOrg.equals("FEISystems")) { RegisteryStoredQueryRequest request = new RegisteryStoredQueryRequest(); AdminContext.getSessionAttributes().setServiceName("DocumentQuery"); setSAMLValues();//from www . j a va 2 s. c o m request.setPatientId( "\'" + patientId + "^^^&" + AdminContext.getSessionAttributes().getSelectedOrgId() + "&ISO\'"); request.setMessageId(messageId); WebServiceFeature features = new AddressingFeature(true); SecuredFilterC32Service service = new SecuredFilterC32Service(); SecuredFilterC32ServicePortType port = service.getSecuredFilterC32Port(features); ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, AdminContext.getSessionAttributes().getSelectedXDSReg()); RegisteryStoredQueryResponse response = port.registeryStoredQuery(request); res = response.getReturn(); AdminContext.getSessionAttributes().setMostRecentSAMLAssertion(tokenSAML.getRECENT_REQUEST()); } else { String gEndpoint = AdminContext.getSessionAttributes().getSelectedXDSReg(); String gUser = AdminContext.getSessionAttributes().getUserId(); String gProviderId = AdminContext.getSessionAttributes().getProviderId(); String gPou = AdminContext.getSessionAttributes().getPurposeOfUse(); String gOrg = AdminContext.getSessionAttributes().getOrganization(); String gOrgUnit = AdminContext.getSessionAttributes().getOrganizationUnit(); String gCity = AdminContext.getSessionAttributes().getCity(); String gState = AdminContext.getSessionAttributes().getState(); String gCountry = AdminContext.getSessionAttributes().getCountry(); String gOrgId = AdminContext.getSessionAttributes().getSelectedOrgId(); System.out.println("****JERICHO ENDPOINT: " + gEndpoint); XdsbRegistryWebServiceClient gWeb = new XdsbRegistryWebServiceClient(gEndpoint, gUser, gProviderId, gPou, gOrg, gOrgUnit, gCity, gState, gCountry, gOrgId); AdhocQueryRequest registryStoredQuery = new AdhocQueryRequest(); ResponseOptionType responseOptionType = new ResponseOptionType(); responseOptionType.setReturnComposedObjects(true); responseOptionType.setReturnType("LeafClass"); registryStoredQuery.setResponseOption(responseOptionType); AdhocQueryType adhocQueryType = new AdhocQueryType(); adhocQueryType.setId("urn:uuid:14d4debf-8f97-4251-9a74-a90016b0af0d"); // FindDocuments // by // patientId registryStoredQuery.setAdhocQuery(adhocQueryType); SlotType1 patientIdSlotType = new SlotType1(); patientIdSlotType.setName("$XDSDocumentEntryPatientId"); ValueListType patientIdValueListType = new ValueListType(); //jericho patient id //patientIdValueListType.getValue().add( // "6^^^&1.2.3.4.5.6.7.8&ISO"); // PatientId if (sOrg.equals("Jericho")) { patientIdValueListType.getValue() .add(patientId + "^^^&" + AdminContext.getSessionAttributes().getSelectedOrgId() + "&ISO"); // PatientId } else { //HIPAAT patientIdValueListType.getValue().add("'" + patientId + "^^^&" + AdminContext.getSessionAttributes().getSelectedOrgId() + "&ISO'"); // PatientId } patientIdSlotType.setValueList(patientIdValueListType); adhocQueryType.getSlot().add(patientIdSlotType); SlotType1 statusSlotType = new SlotType1(); statusSlotType.setName("$XDSDocumentEntryStatus"); ValueListType statusValueListType = new ValueListType(); statusValueListType.getValue().add("('urn:oasis:names:tc:ebxml-regrep:StatusType:Approved')"); statusSlotType.setValueList(statusValueListType); adhocQueryType.getSlot().add(statusSlotType); Object result = gWeb.registryStoredQuery(registryStoredQuery); res = marshall(result); } System.out.println("RESULTS: " + res); return res; }
From source file:com.evolveum.liferay.usercreatehook.ws.ModelPortWrapper.java
private static ModelPortType createModelPort() { String endpointUrl = WSConfig.getEndPointUrl(); String username = WSConfig.getUser(); LOG.info("Endpoint URL: " + endpointUrl); ModelService modelService = new ModelService(); ModelPortType modelPort = modelService.getModelPort(); BindingProvider bp = (BindingProvider) modelPort; // make request context thread safe ((BindingProvider) modelPort).getRequestContext().put("thread.local.request.context", "true"); 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> outProps = new HashMap<String, Object>(); outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN); outProps.put(WSHandlerConstants.USER, username); outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST); outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordHandler.class.getName()); WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps); cxfEndpoint.getOutInterceptors().add(wssOut); return modelPort; }
From source file:com.evolveum.midpoint.testing.model.client.sample.Main.java
public static ModelPortType createModelPort(String[] args) { String endpointUrl = DEFAULT_ENDPOINT_URL; if (args.length > 0) { endpointUrl = args[0];// w ww . j a va2 s. co m } 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)); ModelService modelService = new ModelService(); ModelPortType modelPort = modelService.getModelPort(); 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> outProps = new HashMap<String, Object>(); outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN); outProps.put(WSHandlerConstants.USER, ADM_USERNAME); outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST); outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordHandler.class.getName()); WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps); cxfEndpoint.getOutInterceptors().add(wssOut); // enable the following to get client-side logging of outgoing requests and incoming responses cxfEndpoint.getOutInterceptors().add(new LoggingOutInterceptor()); cxfEndpoint.getInInterceptors().add(new LoggingInInterceptor()); return modelPort; }
From source file:com.evolveum.midpoint.testing.model.client.sample.AbstractTestForExchangeConnector.java
public ModelPortType createModelPort(String[] args) { String endpointUrl = DEFAULT_ENDPOINT_URL; if (args.length > 0) { endpointUrl = args[0];/*from ww w. j av a 2s . c o m*/ } 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)); ModelService modelService = new ModelService(); ModelPortType modelPort = modelService.getModelPort(); 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); HTTPConduit http = (HTTPConduit) client.getConduit(); HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setReceiveTimeout(300000L); http.setClient(httpClientPolicy); org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint(); Map<String, Object> outProps = new HashMap<String, Object>(); outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN); outProps.put(WSHandlerConstants.USER, ADM_USERNAME); outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_DIGEST); outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordHandler.class.getName()); WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps); cxfEndpoint.getOutInterceptors().add(wssOut); // enable the following to get client-side logging of outgoing requests and incoming responses //cxfEndpoint.getOutInterceptors().add(new LoggingOutInterceptor()); //cxfEndpoint.getInInterceptors().add(new LoggingInInterceptor()); return modelPort; }