How to use WebServiceEndpointConfiguration method of com.consol.citrus.ws.server.WebServiceEndpoint class

Best Citrus code snippet using com.consol.citrus.ws.server.WebServiceEndpoint.WebServiceEndpointConfiguration

Source:WebServiceEndpoint.java Github

copy

Full Screen

...17import com.consol.citrus.endpoint.EndpointAdapter;18import com.consol.citrus.endpoint.adapter.EmptyResponseEndpointAdapter;19import com.consol.citrus.exceptions.CitrusRuntimeException;20import com.consol.citrus.message.*;21import com.consol.citrus.ws.client.WebServiceEndpointConfiguration;22import com.consol.citrus.ws.message.*;23import com.consol.citrus.ws.message.SoapFault;24import org.slf4j.Logger;25import org.slf4j.LoggerFactory;26import org.springframework.util.*;27import org.springframework.ws.context.MessageContext;28import org.springframework.ws.mime.MimeMessage;29import org.springframework.ws.server.endpoint.MessageEndpoint;30import org.springframework.ws.soap.*;31import org.springframework.ws.soap.SoapMessage;32import org.springframework.ws.soap.axiom.AxiomSoapMessage;33import org.springframework.ws.soap.saaj.SaajSoapMessage;34import org.springframework.ws.soap.server.endpoint.SoapFaultDefinition;35import org.springframework.ws.soap.soap11.Soap11Body;36import org.springframework.ws.soap.soap12.Soap12Body;37import org.springframework.ws.soap.soap12.Soap12Fault;38import org.springframework.ws.transport.WebServiceConnection;39import org.springframework.ws.transport.context.TransportContextHolder;40import org.springframework.ws.transport.http.HttpServletConnection;41import org.springframework.xml.namespace.QNameUtils;42import org.springframework.xml.transform.StringSource;43import org.w3c.dom.Document;44import javax.xml.namespace.QName;45import javax.xml.soap.MimeHeaders;46import javax.xml.transform.*;47import javax.xml.transform.dom.DOMSource;48import java.io.IOException;49import java.util.List;50import java.util.Map.Entry;51/**52 * SpringWS {@link MessageEndpoint} implementation. Endpoint will delegate message processing to 53 * a {@link EndpointAdapter} implementation.54 * 55 * @author Christoph Deppisch56 */57public class WebServiceEndpoint implements MessageEndpoint {58 /** EndpointAdapter handling incoming requests and providing proper responses */59 private EndpointAdapter endpointAdapter = new EmptyResponseEndpointAdapter();60 61 /** Default namespace for all SOAP header entries */62 private String defaultNamespaceUri;63 64 /** Default prefix for all SOAP header entries */65 private String defaultPrefix = "";66 /** Endpoint configuration */67 private WebServiceEndpointConfiguration endpointConfiguration = new WebServiceEndpointConfiguration();68 /** Logger */69 private static Logger log = LoggerFactory.getLogger(WebServiceEndpoint.class);70 71 /** JMS headers begin with this prefix */72 private static final String DEFAULT_JMS_HEADER_PREFIX = "JMS";73 /**74 * @see org.springframework.ws.server.endpoint.MessageEndpoint#invoke(org.springframework.ws.context.MessageContext)75 * @throws CitrusRuntimeException76 */77 public void invoke(final MessageContext messageContext) throws Exception {78 Assert.notNull(messageContext.getRequest(), "Request must not be null - unable to send message");79 80 Message requestMessage = endpointConfiguration.getMessageConverter().convertInbound(messageContext.getRequest(), messageContext, endpointConfiguration);81 if (log.isDebugEnabled()) {82 log.debug("Received SOAP request:\n" + requestMessage.toString());83 }84 85 //delegate request processing to endpoint adapter86 Message replyMessage = endpointAdapter.handleMessage(requestMessage);87 88 if (simulateHttpStatusCode(replyMessage)) {89 return;90 }91 92 if (replyMessage != null && replyMessage.getPayload() != null) {93 if (log.isDebugEnabled()) {94 log.debug("Sending SOAP response:\n" + replyMessage.toString());95 }96 97 SoapMessage response = (SoapMessage) messageContext.getResponse();98 99 //add soap fault or normal soap body to response100 if (replyMessage instanceof SoapFault) {101 addSoapFault(response, (SoapFault) replyMessage);102 } else {103 addSoapBody(response, replyMessage);104 }105 addSoapAttachments(response, replyMessage);106 addSoapHeaders(response, replyMessage);107 addMimeHeaders(response, replyMessage);108 } else {109 if (log.isDebugEnabled()) {110 log.debug("No reply message from endpoint adapter '" + endpointAdapter + "'");111 }112 log.warn("No SOAP response for calling client");113 }114 }115 private void addSoapAttachments(MimeMessage response, Message replyMessage) {116 if (replyMessage instanceof com.consol.citrus.ws.message.SoapMessage) {117 List<SoapAttachment> soapAttachments = ((com.consol.citrus.ws.message.SoapMessage) replyMessage).getAttachments();118 soapAttachments.stream()119 .filter(soapAttachment -> !soapAttachment.isMtomInline())120 .forEach(soapAttachment -> {121 String contentId = soapAttachment.getContentId();122 if (!contentId.startsWith("<")) {123 contentId = "<" + contentId + ">";124 }125 response.addAttachment(contentId, soapAttachment.getDataHandler());126 });127 }128 }129 /**130 * If Http status code is set on reply message headers simulate Http error with status code.131 * No SOAP response is sent back in this case.132 * @param replyMessage133 * @return134 * @throws IOException 135 */136 private boolean simulateHttpStatusCode(Message replyMessage) throws IOException {137 if (replyMessage == null || CollectionUtils.isEmpty(replyMessage.getHeaders())) {138 return false;139 }140 141 for (Entry<String, Object> headerEntry : replyMessage.getHeaders().entrySet()) {142 if (headerEntry.getKey().equalsIgnoreCase(SoapMessageHeaders.HTTP_STATUS_CODE)) {143 WebServiceConnection connection = TransportContextHolder.getTransportContext().getConnection();144 145 int statusCode = Integer.valueOf(headerEntry.getValue().toString());146 if (connection instanceof HttpServletConnection) {147 ((HttpServletConnection)connection).setFault(false);148 ((HttpServletConnection)connection).getHttpServletResponse().setStatus(statusCode);149 return true;150 } else {151 log.warn("Unable to set custom Http status code on connection other than HttpServletConnection (" + connection.getClass().getName() + ")");152 }153 }154 }155 156 return false;157 }158 /**159 * Adds mime headers outside of SOAP envelope. Header entries that go to this header section 160 * must have internal http header prefix defined in {@link com.consol.citrus.ws.message.SoapMessageHeaders}.161 * @param response the soap response message.162 * @param replyMessage the internal reply message.163 */164 private void addMimeHeaders(SoapMessage response, Message replyMessage) {165 for (Entry<String, Object> headerEntry : replyMessage.getHeaders().entrySet()) {166 if (headerEntry.getKey().toLowerCase().startsWith(SoapMessageHeaders.HTTP_PREFIX)) {167 String headerName = headerEntry.getKey().substring(SoapMessageHeaders.HTTP_PREFIX.length());168 169 if (response instanceof SaajSoapMessage) {170 SaajSoapMessage saajSoapMessage = (SaajSoapMessage) response;171 MimeHeaders headers = saajSoapMessage.getSaajMessage().getMimeHeaders();172 headers.setHeader(headerName, headerEntry.getValue().toString());173 } else if (response instanceof AxiomSoapMessage) {174 log.warn("Unable to set mime message header '" + headerName + "' on AxiomSoapMessage - unsupported");175 } else {176 log.warn("Unsupported SOAP message implementation - unable to set mime message header '" + headerName + "'");177 }178 }179 }180 }181 /**182 * Add message payload as SOAP body element to the SOAP response.183 * @param response184 * @param replyMessage185 */186 private void addSoapBody(SoapMessage response, Message replyMessage) throws TransformerException {187 if (!(replyMessage.getPayload() instanceof String) || 188 StringUtils.hasText(replyMessage.getPayload(String.class))) {189 Source responseSource = getPayloadAsSource(replyMessage.getPayload());190 191 TransformerFactory transformerFactory = TransformerFactory.newInstance();192 Transformer transformer = transformerFactory.newTransformer();193 194 transformer.transform(responseSource, response.getPayloadResult());195 }196 }197 198 /**199 * Translates message headers to SOAP headers in response.200 * @param response201 * @param replyMessage202 */203 private void addSoapHeaders(SoapMessage response, Message replyMessage) throws TransformerException {204 for (Entry<String, Object> headerEntry : replyMessage.getHeaders().entrySet()) {205 if (MessageHeaderUtils.isSpringInternalHeader(headerEntry.getKey()) ||206 headerEntry.getKey().startsWith(DEFAULT_JMS_HEADER_PREFIX)) {207 continue;208 }209 if (headerEntry.getKey().equalsIgnoreCase(SoapMessageHeaders.SOAP_ACTION)) {210 response.setSoapAction(headerEntry.getValue().toString());211 } else if (!headerEntry.getKey().startsWith(MessageHeaders.PREFIX)) {212 SoapHeaderElement headerElement;213 if (QNameUtils.validateQName(headerEntry.getKey())) {214 QName qname = QNameUtils.parseQNameString(headerEntry.getKey());215 if (StringUtils.hasText(qname.getNamespaceURI())) {216 headerElement = response.getSoapHeader().addHeaderElement(qname);217 } else {218 headerElement = response.getSoapHeader().addHeaderElement(getDefaultQName(headerEntry.getKey()));219 }220 } else {221 throw new SoapHeaderException("Failed to add SOAP header '" + headerEntry.getKey() + "', " +222 "because of invalid QName");223 }224 headerElement.setText(headerEntry.getValue().toString());225 }226 }227 for (String headerData : replyMessage.getHeaderData()) {228 TransformerFactory transformerFactory = TransformerFactory.newInstance();229 Transformer transformer = transformerFactory.newTransformer();230 transformer.transform(new StringSource(headerData),231 response.getSoapHeader().getResult());232 }233 }234 /**235 * Adds a SOAP fault to the SOAP response body. The SOAP fault is declared236 * as QName string in the response message's header (see {@link com.consol.citrus.ws.message.SoapMessageHeaders})237 * 238 * @param response239 * @param replyMessage240 */241 private void addSoapFault(SoapMessage response, SoapFault replyMessage) throws TransformerException {242 SoapBody soapBody = response.getSoapBody();243 org.springframework.ws.soap.SoapFault soapFault;244 245 if (SoapFaultDefinition.SERVER.equals(replyMessage.getFaultCodeQName()) ||246 SoapFaultDefinition.RECEIVER.equals(replyMessage.getFaultCodeQName())) {247 soapFault = soapBody.addServerOrReceiverFault(replyMessage.getFaultString(),248 replyMessage.getLocale());249 } else if (SoapFaultDefinition.CLIENT.equals(replyMessage.getFaultCodeQName()) ||250 SoapFaultDefinition.SENDER.equals(replyMessage.getFaultCodeQName())) {251 soapFault = soapBody.addClientOrSenderFault(replyMessage.getFaultString(),252 replyMessage.getLocale());253 } else if (soapBody instanceof Soap11Body) {254 Soap11Body soap11Body = (Soap11Body) soapBody;255 soapFault = soap11Body.addFault(replyMessage.getFaultCodeQName(),256 replyMessage.getFaultString(),257 replyMessage.getLocale());258 } else if (soapBody instanceof Soap12Body) {259 Soap12Body soap12Body = (Soap12Body) soapBody;260 Soap12Fault soap12Fault = soap12Body.addServerOrReceiverFault(replyMessage.getFaultString(),261 replyMessage.getLocale());262 soap12Fault.addFaultSubcode(replyMessage.getFaultCodeQName());263 264 soapFault = soap12Fault;265 } else {266 throw new CitrusRuntimeException("Found unsupported SOAP implementation. Use SOAP 1.1 or SOAP 1.2.");267 }268 269 if (replyMessage.getFaultActor() != null) {270 soapFault.setFaultActorOrRole(replyMessage.getFaultActor());271 }272 273 List<String> soapFaultDetails = replyMessage.getFaultDetails();274 if (!soapFaultDetails.isEmpty()) {275 TransformerFactory transformerFactory = TransformerFactory.newInstance();276 Transformer transformer = transformerFactory.newTransformer();277 278 transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");279 280 SoapFaultDetail faultDetail = soapFault.addFaultDetail();281 for (int i = 0; i < soapFaultDetails.size(); i++) {282 transformer.transform(new StringSource(soapFaultDetails.get(i)), faultDetail.getResult());283 }284 }285 }286 287 /**288 * Get the message payload object as {@link Source}, supported payload types are289 * {@link Source}, {@link Document} and {@link String}.290 * @param replyPayload payload object291 * @return {@link Source} representation of the payload292 */293 private Source getPayloadAsSource(Object replyPayload) {294 if (replyPayload instanceof Source) {295 return (Source) replyPayload;296 } else if (replyPayload instanceof Document) {297 return new DOMSource((Document) replyPayload);298 } else if (replyPayload instanceof String) {299 return new StringSource((String) replyPayload);300 } else {301 throw new CitrusRuntimeException("Unknown type for reply message payload (" + replyPayload.getClass().getName() + ") " +302 "Supported types are " + "'" + Source.class.getName() + "', " + "'" + Document.class.getName() + "'" + 303 ", or '" + String.class.getName() + "'");304 }305 }306 /**307 * Get the default QName from local part.308 * @param localPart309 * @return310 */311 private QName getDefaultQName(String localPart) {312 if (StringUtils.hasText(defaultNamespaceUri)) {313 return new QName(defaultNamespaceUri, localPart, defaultPrefix);314 } else {315 throw new SoapHeaderException("Failed to add SOAP header '" + localPart + "', " +316 "because neither valid QName nor default namespace-uri is set!");317 }318 }319 /**320 * Gets the endpoint adapter.321 * @return322 */323 public EndpointAdapter getEndpointAdapter() {324 return endpointAdapter;325 }326 /**327 * Set the endpoint adapter.328 * @param endpointAdapter the endpointAdapter to set329 */330 public void setEndpointAdapter(EndpointAdapter endpointAdapter) {331 this.endpointAdapter = endpointAdapter;332 }333 /**334 * Gets the default header namespace uri.335 * @return336 */337 public String getDefaultNamespaceUri() {338 return defaultNamespaceUri;339 }340 /**341 * Set the default namespace used in SOAP response headers.342 * @param defaultNamespaceUri the defaultNamespaceUri to set343 */344 public void setDefaultNamespaceUri(String defaultNamespaceUri) {345 this.defaultNamespaceUri = defaultNamespaceUri;346 }347 /**348 * Gets the default header prefix.349 * @return350 */351 public String getDefaultPrefix() {352 return defaultPrefix;353 }354 /**355 * Set the default namespace prefix used in SOAP response headers.356 * @param defaultPrefix the defaultPrefix to set357 */358 public void setDefaultPrefix(String defaultPrefix) {359 this.defaultPrefix = defaultPrefix;360 }361 /**362 * Gets the endpoint configuration.363 * @return364 */365 public WebServiceEndpointConfiguration getEndpointConfiguration() {366 return endpointConfiguration;367 }368 /**369 * Sets the endpoint configuration.370 * @param endpointConfiguration371 */372 public void setEndpointConfiguration(WebServiceEndpointConfiguration endpointConfiguration) {373 this.endpointConfiguration = endpointConfiguration;374 }375}...

Full Screen

Full Screen

Source:CitrusMessageDispatcherServlet.java Github

copy

Full Screen

...15 */16package com.consol.citrus.ws.servlet;17import com.consol.citrus.endpoint.EndpointAdapter;18import com.consol.citrus.ws.server.WebServiceEndpoint;19import com.consol.citrus.ws.client.WebServiceEndpointConfiguration;20import com.consol.citrus.ws.interceptor.DelegatingEndpointInterceptor;21import com.consol.citrus.ws.server.WebServiceServer;22import org.springframework.context.ApplicationContext;23import org.springframework.util.StringUtils;24import org.springframework.ws.server.EndpointInterceptor;25import org.springframework.ws.transport.http.MessageDispatcherServlet;26import java.util.ArrayList;27import java.util.List;28/**29 * Citrus message dispatcher servlet extends Spring's message dispatcher servlet and just30 * adds optional configuration settings for default mapping strategies, interceptors and so on.31 *32 * @author Christoph Deppisch33 * @since 1.434 */35public class CitrusMessageDispatcherServlet extends MessageDispatcherServlet {36 /** Soap web server hosting the servlet */37 private WebServiceServer webServiceServer;38 /** Default bean names used in default configuration */39 private static final String ENDPOINT_INTERCEPTOR_BEAN_NAME = "citrusEndpointInterceptor";40 private static final String MESSAGE_ENDPOINT_BEAN_NAME = "citrusWsEndpoint";41 /**42 * Default constructor using http server instance that43 * holds this servlet.44 * @param webServiceServer45 */46 public CitrusMessageDispatcherServlet(WebServiceServer webServiceServer) {47 this.webServiceServer = webServiceServer;48 //use this message factory bean name - users can specify custom factories for SOAP 1.2 for instance49 setMessageFactoryBeanName(webServiceServer.getMessageFactoryName());50 }51 @Override52 protected void initStrategies(ApplicationContext context) {53 super.initStrategies(context);54 configureHandlerInterceptor(context);55 configureMessageEndpoint(context);56 }57 /**58 * Post process handler interceptors.59 * @param context60 */61 protected void configureHandlerInterceptor(ApplicationContext context) {62 if (context.containsBean(ENDPOINT_INTERCEPTOR_BEAN_NAME)) {63 DelegatingEndpointInterceptor endpointInterceptor = context.getBean(ENDPOINT_INTERCEPTOR_BEAN_NAME, DelegatingEndpointInterceptor.class);64 endpointInterceptor.setInterceptors(adaptInterceptors(webServiceServer.getInterceptors()));65 }66 }67 /**68 * Post process endpoint.69 * @param context70 */71 protected void configureMessageEndpoint(ApplicationContext context) {72 if (context.containsBean(MESSAGE_ENDPOINT_BEAN_NAME)) {73 WebServiceEndpoint messageEndpoint = context.getBean(MESSAGE_ENDPOINT_BEAN_NAME, WebServiceEndpoint.class);74 EndpointAdapter endpointAdapter = webServiceServer.getEndpointAdapter();75 if (endpointAdapter != null) {76 messageEndpoint.setEndpointAdapter(endpointAdapter);77 }78 WebServiceEndpointConfiguration endpointConfiguration = new WebServiceEndpointConfiguration();79 endpointConfiguration.setHandleMimeHeaders(webServiceServer.isHandleMimeHeaders());80 endpointConfiguration.setHandleAttributeHeaders(webServiceServer.isHandleAttributeHeaders());81 endpointConfiguration.setKeepSoapEnvelope(webServiceServer.isKeepSoapEnvelope());82 endpointConfiguration.setMessageConverter(webServiceServer.getMessageConverter());83 messageEndpoint.setEndpointConfiguration(endpointConfiguration);84 if (StringUtils.hasText(webServiceServer.getSoapHeaderNamespace())) {85 messageEndpoint.setDefaultNamespaceUri(webServiceServer.getSoapHeaderNamespace());86 }87 if (StringUtils.hasText(webServiceServer.getSoapHeaderPrefix())) {88 messageEndpoint.setDefaultPrefix(webServiceServer.getSoapHeaderPrefix());89 }90 }91 }92 /**...

Full Screen

Full Screen

WebServiceEndpointConfiguration

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws.server;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.testng.CitrusParameters;4import com.consol.citrus.ws.client.WebServiceClient;5import org.springframework.beans.factory.annotation.Autowired;6import org.testng.annotations.Test;7public class WebServiceEndpointConfigurationIT extends AbstractWebServiceServerIT {8 private WebServiceClient webServiceClient;9 @CitrusParameters("endpointName")10 public void testWebServiceEndpointConfiguration(String endpointName) {11 WebServiceEndpointConfiguration endpointConfiguration = new WebServiceEndpointConfiguration();12 endpointConfiguration.setEndpointName(endpointName);13 endpointConfiguration.setPort(8080);14 endpointConfiguration.setContextPath("/test");15 endpointConfiguration.setServletPath("/test");16 endpointConfiguration.setWsdlPath("classpath:com/consol/citrus/ws/HelloWorldService.wsdl");17 endpointConfiguration.setEndpointAdapter(new HelloWorldEndpointAdapter());18 WebServiceEndpointConfiguration endpointConfiguration2 = new WebServiceEndpointConfiguration();19 endpointConfiguration2.setEndpointName(endpointName);20 endpointConfiguration2.setPort(8080);21 endpointConfiguration2.setContextPath("/test");22 endpointConfiguration2.setServletPath("/test");23 endpointConfiguration2.setWsdlPath("classpath:com/consol/citrus/ws/HelloWorldService.wsdl");24 endpointConfiguration2.setEndpointAdapter(new HelloWorldEndpointAdapter());25 WebServiceEndpointConfiguration endpointConfiguration3 = new WebServiceEndpointConfiguration();26 endpointConfiguration3.setEndpointName(endpointName);27 endpointConfiguration3.setPort(8080);28 endpointConfiguration3.setContextPath("/test");29 endpointConfiguration3.setServletPath("/test");30 endpointConfiguration3.setWsdlPath("classpath:com/consol/citrus/ws/HelloWorldService.wsdl");31 endpointConfiguration3.setEndpointAdapter(new HelloWorldEndpointAdapter());32 endpointConfiguration.start();33 endpointConfiguration2.start();34 endpointConfiguration3.start();35 webServiceClient.send(endpointName);36 endpointConfiguration.stop();37 endpointConfiguration2.stop();38 endpointConfiguration3.stop();39 }40}41package com.consol.citrus.ws.server;42import com.consol.citrus.annotations.CitrusTest;43import com.consol.citrus.ws.client.WebServiceClient;44import org.springframework.beans.factory.annotation.Autowired;45import org.testng.annotations.Test;

Full Screen

Full Screen

WebServiceEndpointConfiguration

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.demo;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;4import com.consol.citrus.ws.client.WebServiceClient;5import com.consol.citrus.ws.server.WebServiceEndpoint;6import org.springframework.beans.factory.annotation.Autowired;7import org.springframework.beans.factory.annotation.Qualifier;8import org.testng.annotations.Test;9import static com.consol.citrus.actions.CreateVariablesAction.Builder.createVariable;10import static com.consol.citrus.actions.EchoAction.Builder.echo;11import static com.consol.citrus.actions.ExecutePLSQLAction.Builder.executePLSQL;12import static com.consol.citrus.actions.ExecutePLSQLAction.Builder.executePLSQLBuilder;13import static com.consol.citrus.actions.PurgeJmsQueuesAction.Builder.purgeQueues;14import static com.consol.citrus.actions.SendMessageAction.Builder.sendMessage;15import static com.consol.citrus.actions.SleepAction.Builder.sleep;16import static com.consol.citrus.actions.StopTimeAction.Builder.stopTime;17import static com.consol.citrus.actions.StopT

Full Screen

Full Screen

WebServiceEndpointConfiguration

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws.server;2import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;3import com.consol.citrus.ws.message.SoapAttachment;4import org.springframework.core.io.ClassPathResource;5import org.testng.annotations.Test;6public class WebServiceEndpointConfiguration extends TestNGCitrusTestRunner {7public void WebServiceEndpointConfiguration() {8WebServiceEndpoint webServiceEndpoint = new WebServiceEndpoint();9webServiceEndpoint.setEndpointConfiguration(endpointConfig());10webServiceEndpoint.setPort(8080);11webServiceEndpoint.setEndpointAdapter(endpointAdapter());12webServiceEndpoint.setApplicationContext(applicationContext);13webServiceEndpoint.setInterceptors(interceptors());14webServiceEndpoint.init();15webServiceEndpoint.start();16}17}18package com.consol.citrus.ws.server;19import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;20import com.consol.citrus.ws.message.SoapAttachment;21import org.springframework.core.io.ClassPathResource;22import org.testng.annotations.Test;23public class WebServiceEndpointConfiguration extends TestNGCitrusTestRunner {24public void WebServiceEndpointConfiguration() {25WebServiceEndpoint webServiceEndpoint = new WebServiceEndpoint();26webServiceEndpoint.setEndpointConfiguration(endpointConfig());27webServiceEndpoint.setPort(8080);28webServiceEndpoint.setEndpointAdapter(endpointAdapter());29webServiceEndpoint.setApplicationContext(applicationContext);30webServiceEndpoint.setInterceptors(interceptors());31webServiceEndpoint.init();32webServiceEndpoint.start();33}34}35package com.consol.citrus.ws.server;36import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;37import com.consol.citrus.ws.message.SoapAttachment;38import org.springframework.core.io.ClassPathResource;39import org.testng.annotations.Test;40public class WebServiceEndpointConfiguration extends TestNGCitrusTestRunner {41public void WebServiceEndpointConfiguration() {42WebServiceEndpoint webServiceEndpoint = new WebServiceEndpoint();43webServiceEndpoint.setEndpointConfiguration(endpointConfig());44webServiceEndpoint.setPort(8080);45webServiceEndpoint.setEndpointAdapter(endpointAdapter());46webServiceEndpoint.setApplicationContext(applicationContext);47webServiceEndpoint.setInterceptors(interceptors());48webServiceEndpoint.init();49webServiceEndpoint.start();50}51}

Full Screen

Full Screen

WebServiceEndpointConfiguration

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.samples;2import com.consol.citrus.annotations.CitrusTest;3import com.consol.citrus.dsl.junit.JUnit4CitrusTestRunner;4import com.consol.citrus.dsl.runner.TestRunner;5import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;6import com.consol.citrus.ws.client.WebServiceClient;7import com.consol.citrus.ws.message.SoapAttachment;8import com.consol.citrus.ws.server.WebServiceEndpoint;9import org.springframework.beans.factory.annotation.Autowired;10import org.springframework.core.io.ClassPathResource;11import org.springframework.ws.soap.SoapMessage;12import org.testng.annotations.Test;13import java.util.Collections;14import java.util.HashMap;15import java.util.Map;16public class WebServiceEndpointConfigurationTest extends JUnit4CitrusTestRunner {17 private WebServiceClient webServiceClient;18 private WebServiceEndpoint webServiceEndpoint;19 public void testWebServiceEndpointConfiguration() {20 webServiceEndpoint.configuration()21 .autoStart(false)22 .port(8082)23 .timeout(5000L)24 .schemaValidation(true)25 .soapVersion11(true)26 .attachments(Collections.singletonList(new SoapAttachment("testAttachment", new ClassPathResource("com/consol/citrus/samples/attachment.txt"), "text/plain")))27 .schemaValidation(true)28 .schemaValidation(true)29 .schemaValidation(true)

Full Screen

Full Screen

WebServiceEndpointConfiguration

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus;2import com.consol.citrus.dsl.endpoint.CitrusEndpoints;3import com.consol.citrus.ws.server.WebServiceEndpoint;4import com.consol.citrus.ws.server.WebServiceEndpointConfiguration;5import org.springframework.context.annotation.Bean;6import org.springframework.context.annotation.Configuration;7public class WebServiceEndpointConfig {8 public WebServiceEndpoint webServiceEndpoint() {9 WebServiceEndpointConfiguration endpointConfiguration = new WebServiceEndpointConfiguration();10 endpointConfiguration.setPort(8080);11 endpointConfiguration.setContextPath("/test");12 .soap()13 .server()14 .endpointConfiguration(endpointConfiguration)15 .build();16 }17}18package com.consol.citrus;19import com.consol.citrus.ws.server.WebServiceEndpointConfiguration;20import org.springframework.beans.factory.annotation.Value;21import org.springframework.context.annotation.Configuration;22public class CustomWebServiceEndpointConfiguration extends WebServiceEndpointConfiguration {23 @Value("${custom.ws.port}")24 private int port;25 @Value("${custom.ws.context-path}")26 private String contextPath;27 public int getPort() {28 return port;29 }30 public String getContextPath() {31 return contextPath;32 }33}34package com.consol.citrus;35import com.consol.citrus.dsl.runner.TestRunner;36import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;37import com.consol.citrus.ws.server.WebServiceEndpoint;38import org.springframework.beans.factory.annotation.Autowired;39import org.springframework.beans.factory.annotation.Qualifier;40import org.testng.annotations.Test;41public class WebServiceEndpointConfigIT extends TestNGCitrusTestRunner {42 @Qualifier("webServiceEndpoint")43 private WebServiceEndpoint webServiceEndpoint;44 protected void configure(TestRunner runner) {45 runner.http(action -> action.client("httpClient")46 .send()47 .get("/test"));48 runner.http(action -> action.client("httpClient")49 .receive()50 .response(HttpStatus.OK));51 }52}53package com.consol.citrus;54import com

Full Screen

Full Screen

WebServiceEndpointConfiguration

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;2public class 3 extends TestNGCitrusTestDesigner {3 public void 3() {4 variable("port", "8080");5 variable("contextPath", "test");6 variable("serviceName", "testService");7 variable("wsdl", "classpath:com/consol/citrus/ws/HelloService.wsdl");8 variable("operation", "sayHello");9 variable("contentType", "text/xml");10 variable("charset", "UTF-8");11 variable("faultCode", "SOAP-ENV:Server");12 variable("faultString", "Internal Server Error");13 variable("faultDetail", "<faultDetail>Internal Server Error</faultDetail>");14 variable("faultContentType", "text/xml");15 variable("faultCharset", "UTF-8");16 variable("endpointConfiguration", "citrus:variable('endpointConfiguration')");17 variable("endpointUrl", "citrus:variable('endpointUrl')");18 variable("endpoint", "citrus:variable('endpoint')");19 variable("requestPayload", "citrus:payload()");20 variable("responsePayload", "citrus:payload()");21 variable("faultPayload", "citrus:payload()");22 variable("messagePayload", "citrus:payload()");23 variable("faultMessagePayload", "citrus:payload()");24 variable("messageHeaders", "citrus:headers()");25 variable("messageHeader", "citrus:header('operation')");26 variable("messageHeaderName", "operation");

Full Screen

Full Screen

WebServiceEndpointConfiguration

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.ws.server;2import org.springframework.context.annotation.Bean;3import org.springframework.context.annotation.Configuration;4import org.springframework.context.annotation.Import;5import org.springframework.ws.soap.SoapVersion;6import org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor;7import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;8import org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor;9import org.springframework.ws.soap.security.wss4j.support.CryptoFactoryBean;10import org.springframework.ws.soap.security.wss4j.support.KeyStoreFactoryBean;11import org.springframework.ws.soap.security.wss4j.support.PasswordKeyStoreCallbackHandler;12import org.springframework.ws.soap.security.wss4j.support.callback.SimplePasswordValidationCallbackHandler;13import org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor;14import org.springframework.ws.soap.security.xwss.callback.KeyStoreCallbackHandler;15import org.springframework.ws.soap.security.xwss.callback.SimplePasswordValidationCallback;16import org.springframework.ws.transport.http.MessageDispatcherServlet;17import org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter;18import org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition;19import org.springframework.xml.xsd.SimpleXsdSchema;20import org.springframework.xml.xsd.XsdSchema;21import org.springframework.ws.soap.security.xwss.callback.KeyStoreCallbackHandler;22import com.consol.citrus.ws.actions.WebServiceClientAction;23import com.consol.citrus.ws.client.WebServiceClient;24import com.consol.citrus.ws.client.WebServiceClientBuilder;25import com.consol.citrus.ws.message.SoapAttachment;26import com.consol.citrus.ws.message.SoapMessage;27import com.consol.citrus.ws.message.SoapMessageConverter;28import com.consol.citrus.ws.message.SoapMessageHeaders;29import com.consol.citrus.ws.message.SoapMessageValidationContext;30import com.consol.citrus.ws.message.SoapMessageValidator;31import com.consol.citrus.ws.message.converter.MarshallingSoapMessageConverter;32import com.consol.citrus.ws.message.converter.SoapAttachmentMessageConverter;33import com.consol.citrus.ws.message.converter.SoapMessageMarshaller;34import com.consol.citrus.ws.message.converter.SoapMessageUnmarshaller;35import com.consol.citrus.ws.message.converter.UnmarshallingSoapMessageConverter;36import com.con

Full Screen

Full Screen

WebServiceEndpointConfiguration

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.demo;2import com.consol.citrus.dsl.design.TestDesigner;3import com.consol.citrus.dsl.design.TestDesignerBeforeSuiteSupport;4import com.consol.citrus.ws.client.WebServiceClient;5import com.consol.citrus.ws.server.WebServiceEndpoint;6import com.consol.citrus.ws.server.WebServiceEndpointConfiguration;7import org.springframework.beans.factory.annotation.Autowired;8import org.springframework.beans.factory.annotation.Qualifier;9import org.springframework.context.annotation.Bean;10import org.springframework.context.annotation.Configuration;11import org.springframework.context.annotation.DependsOn;12import org.springframework.ws.soap.server.SoapMessageDispatcher;13import javax.xml.namespace.QName;14public class WebServiceEndpointConfigurationTest extends TestDesignerBeforeSuiteSupport {15 @Qualifier("webServiceClient")16 private WebServiceClient webServiceClient;17 @Qualifier("soapMessageDispatcher")18 private SoapMessageDispatcher soapMessageDispatcher;19 @DependsOn("startServer")20 public TestDesigner webServiceEndpointConfigurationTest() {21 return new TestDesigner() {22 public void configure() {23 echo("WebServiceEndpointConfiguration method demo");24 WebServiceEndpointConfiguration webServiceEndpointConfiguration = new WebServiceEndpointConfiguration();25 webServiceEndpointConfiguration.setSoapMessageDispatcher(soapMessageDispatcher);26 webServiceEndpointConfiguration.setWsdl("classpath:wsdl/HelloService.wsdl");27 webServiceEndpointConfiguration.setEndpointMappingPath("classpath:wsdl/HelloService-endpoint-mapping.properties");28 webServiceEndpointConfiguration.setEndpointAdapter(webServiceClient.getEndpointAdapter());29 WebServiceEndpoint webServiceEndpoint = new WebServiceEndpoint();30 webServiceEndpoint.setName("helloService");31 webServiceEndpoint.setConfiguration(webServiceEndpointConfiguration);32 webServiceEndpoint.create();33 send(webServiceClient)

Full Screen

Full Screen

WebServiceEndpointConfiguration

Using AI Code Generation

copy

Full Screen

1public void test() {2 WebServiceEndpointConfiguration endpointConfiguration = new WebServiceEndpointConfiguration();3 endpointConfiguration.setPort(8080);4 endpointConfiguration.setContextPath("/test");5 endpointConfiguration.setEndpointAdapter(new SoapEndpointAdapter());6 endpointConfiguration.setEndpointMappingStrategy(new DefaultEndpointMappingStrategy());7 WebServiceEndpoint endpoint = new WebServiceEndpoint(endpointConfiguration);8 endpoint.create();9 endpoint.start();10 endpoint.stop();11 endpoint.destroy();12}13public void test() {14 WebServiceEndpointConfiguration endpointConfiguration = new WebServiceEndpointConfiguration();15 endpointConfiguration.setPort(8080);16 endpointConfiguration.setContextPath("/test");17 endpointConfiguration.setEndpointAdapter(new SoapEndpointAdapter());18 endpointConfiguration.setEndpointMappingStrategy(new DefaultEndpointMappingStrategy());19 WebServiceEndpoint endpoint = new WebServiceEndpoint(endpointConfiguration);20 endpoint.create();21 endpoint.start();22 endpoint.stop();23 endpoint.destroy();24}25public void test() {26 WebServiceEndpointConfiguration endpointConfiguration = new WebServiceEndpointConfiguration();27 endpointConfiguration.setPort(8080);28 endpointConfiguration.setContextPath("/test");29 endpointConfiguration.setEndpointAdapter(new SoapEndpointAdapter());30 endpointConfiguration.setEndpointMappingStrategy(new DefaultEndpointMappingStrategy());31 WebServiceEndpoint endpoint = new WebServiceEndpoint(endpointConfiguration);32 endpoint.create();33 endpoint.start();34 endpoint.stop();35 endpoint.destroy();36}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful