/** * Configure the provided {@link WebServiceTemplate} instance using this builder. * @param <T> the type of web service template * @param webServiceTemplate the {@link WebServiceTemplate} to configure * @return the web service template instance * @see #build() * @see #build(Class) */ public <T extends WebServiceTemplate> T configure(T webServiceTemplate) { Assert.notNull(webServiceTemplate, "WebServiceTemplate must not be null"); configureMessageSenders(webServiceTemplate); PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); applyCustomizers(webServiceTemplate, this.internalCustomizers); map.from(this.marshaller).to(webServiceTemplate::setMarshaller); map.from(this.unmarshaller).to(webServiceTemplate::setUnmarshaller); map.from(this.destinationProvider).to(webServiceTemplate::setDestinationProvider); map.from(this.transformerFactoryClass) .to(webServiceTemplate::setTransformerFactoryClass); map.from(this.messageFactory).to(webServiceTemplate::setMessageFactory); if (!CollectionUtils.isEmpty(this.interceptors)) { Set<ClientInterceptor> merged = new LinkedHashSet<>(this.interceptors); if (webServiceTemplate.getInterceptors() != null) { merged.addAll(Arrays.asList(webServiceTemplate.getInterceptors())); } webServiceTemplate.setInterceptors(merged.toArray(new ClientInterceptor[0])); } applyCustomizers(webServiceTemplate, this.customizers); return webServiceTemplate; }
/** Returns the {@code ClientInterceptors} used by the template. */ public final ClientInterceptor[] getInterceptors() { return webServiceTemplate.getInterceptors(); }
/** Returns the {@code ClientInterceptors} used by the template. */ public final ClientInterceptor[] getInterceptors() { return webServiceTemplate.getInterceptors(); }
/** Returns the <code>ClientInterceptors</code> used by the template. */ public final ClientInterceptor[] getInterceptors() { return webServiceTemplate.getInterceptors(); }
/** Returns the {@code ClientInterceptors} used by the template. */ public final ClientInterceptor[] getInterceptors() { return webServiceTemplate.getInterceptors(); }
@Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof WebServiceTemplate) { final WebServiceTemplate webServiceTemplate = (WebServiceTemplate)bean; final ClientInterceptor[] interceptors = webServiceTemplate.getInterceptors(); final ClientInterceptor[] newInterceptors; if (interceptors != null) { newInterceptors = Arrays.copyOf(interceptors, interceptors.length+1); } else { newInterceptors = new ClientInterceptor[1]; } newInterceptors[newInterceptors.length-1] = interceptor; webServiceTemplate.setInterceptors(newInterceptors); } return bean; } @Override
/** * Creates a {@code MockWebServiceServer} instance based on the given {@link WebServiceTemplate}. * Supports interceptors that will be applied on the incomming message. Please note that acctually the interceptoes will * be added to the {@link ClientInterceptor} set on the client side. it's an ugly hack, but that's the only way to do it * without reimplementing the whole testing library. I hope it will change in next releases. * * @param webServiceTemplate the web service template * @return the created server */ public static MockWebServiceServer createServer(WebServiceTemplate webServiceTemplate, EndpointInterceptor[] interceptors) { if (interceptors!=null && interceptors.length>0) { List<ClientInterceptor> newInterceptors = new ArrayList<ClientInterceptor>(); if (webServiceTemplate.getInterceptors()!=null) { newInterceptors.addAll(Arrays.asList(webServiceTemplate.getInterceptors())); } newInterceptors.addAll(Arrays.asList(EndpointInterceptorClientAdapter.wrapEndpointInterceptors(interceptors))); webServiceTemplate.setInterceptors(newInterceptors.toArray(new ClientInterceptor[newInterceptors.size()])); } return MockWebServiceServer.createServer(webServiceTemplate); }
public Object invoke(MethodInvocation arg0) throws Throwable { for (int i = 0; i < getWebServiceTemplate().getInterceptors().length; i++) { if(getWebServiceTemplate().getInterceptors()[i] instanceof Wss4jSecurityInterceptor) { if(securementCredentialsProvider == null) { throw new ClientItcbException(ClientItcbExceptionMappingErrors.COMMON_CLIENT_NOT_SET_SECUREMENT_PROVIDER, messageSource.getMessage("common-client.exception.not_set_securement_provider", new Object[] {arg0.getMethod()}, LocaleContextHolder.getLocale())); Wss4jSecurityInterceptor securityInterceptor = (Wss4jSecurityInterceptor)getWebServiceTemplate().getInterceptors()[i]; if(user!= null) { securityInterceptor.setSecurementUsername(user.getUsername());