How to use SoapMessage method of com.consol.citrus.dsl.builder.SoapClientRequestActionBuilder class

Best Citrus code snippet using com.consol.citrus.dsl.builder.SoapClientRequestActionBuilder.SoapMessage

Source:SoapClientRequestActionBuilder.java Github

copy

Full Screen

...20import com.consol.citrus.endpoint.resolver.DynamicEndpointUriResolver;21import com.consol.citrus.exceptions.CitrusRuntimeException;22import com.consol.citrus.util.FileUtils;23import com.consol.citrus.validation.builder.StaticMessageContentBuilder;24import com.consol.citrus.ws.actions.SendSoapMessageAction;25import com.consol.citrus.ws.message.*;26import org.springframework.core.io.Resource;27import java.io.IOException;28import java.nio.charset.Charset;29/**30 * @author Christoph Deppisch31 * @since 2.632 */33public class SoapClientRequestActionBuilder extends SendMessageBuilder<SendSoapMessageAction, SoapClientRequestActionBuilder> {34 /** Soap message to send or receive */35 private SoapMessage soapMessage = new SoapMessage();36 /**37 * Default constructor using soap client endpoint.38 * @param delegate39 * @param soapClient40 */41 public SoapClientRequestActionBuilder(DelegatingTestAction<TestAction> delegate, Endpoint soapClient) {42 super(delegate);43 delegate.setDelegate(new SendSoapMessageAction());44 getAction().setEndpoint(soapClient);45 getAction().setMessageBuilder(new StaticMessageContentBuilder(soapMessage));46 }47 /**48 * Default constructor using soap client uri.49 * @param delegate50 * @param soapClientUri51 */52 public SoapClientRequestActionBuilder(DelegatingTestAction<TestAction> delegate, String soapClientUri) {53 super(delegate);54 delegate.setDelegate(new SendSoapMessageAction());55 getAction().setEndpointUri(soapClientUri);56 getAction().setMessageBuilder(new StaticMessageContentBuilder(soapMessage));57 }58 @Override59 protected void setPayload(String payload) {60 soapMessage.setPayload(payload);61 }62 /**63 * Sets special SOAP action message header.64 * @param soapAction65 * @return66 */67 public SoapClientRequestActionBuilder soapAction(String soapAction) {68 soapMessage.header(SoapMessageHeaders.SOAP_ACTION, soapAction);69 return this;70 }71 /**72 * Sets the attachment with string content.73 * @param contentId74 * @param contentType75 * @param content76 * @return77 */78 public SoapClientRequestActionBuilder attachment(String contentId, String contentType, String content) {79 SoapAttachment attachment = new SoapAttachment();80 attachment.setContentId(contentId);81 attachment.setContentType(contentType);82 attachment.setContent(content);83 getAction().getAttachments().add(attachment);84 return this;85 }86 /**87 * Sets the attachment with content resource.88 * @param contentId89 * @param contentType90 * @param contentResource91 * @return92 */93 public SoapClientRequestActionBuilder attachment(String contentId, String contentType, Resource contentResource) {94 return attachment(contentId, contentType, contentResource, FileUtils.getDefaultCharset());95 }96 /**97 * Sets the attachment with content resource.98 * @param contentId99 * @param contentType100 * @param contentResource101 * @param charset102 * @return103 */104 public SoapClientRequestActionBuilder attachment(String contentId, String contentType, Resource contentResource, Charset charset) {105 SoapAttachment attachment = new SoapAttachment();106 attachment.setContentId(contentId);107 attachment.setContentType(contentType);108 try {109 attachment.setContent(FileUtils.readToString(contentResource, charset));110 } catch (IOException e) {111 throw new CitrusRuntimeException("Failed to read attachment resource", e);112 }113 getAction().getAttachments().add(attachment);114 return this;115 }116 /**117 * Sets the charset name for this send action builder's attachment.118 * @param charsetName119 * @return120 */121 public SoapClientRequestActionBuilder charset(String charsetName) {122 if (!getAction().getAttachments().isEmpty()) {123 getAction().getAttachments().get(getAction().getAttachments().size() - 1).setCharsetName(charsetName);124 }125 return this;126 }127 /**128 * Sets the attachment from Java object instance.129 * @param attachment130 * @return131 */132 public SoapClientRequestActionBuilder attachment(SoapAttachment attachment) {133 getAction().getAttachments().add(attachment);134 return this;135 }136 /**137 * Set the endpoint URI for the request. This works only if the HTTP endpoint used138 * doesn't provide an own endpoint URI resolver.139 *140 * @param uri absolute URI to use for the endpoint141 * @return self142 */143 public SoapClientRequestActionBuilder uri(String uri) {144 soapMessage.header(DynamicEndpointUriResolver.ENDPOINT_URI_HEADER_NAME, uri);145 return this;146 }147 /**148 * Sets the request content type header.149 * @param contentType150 * @return151 */152 public SoapClientRequestActionBuilder contentType(String contentType) {153 soapMessage.header(SoapMessageHeaders.HTTP_CONTENT_TYPE, contentType);154 return this;155 }156 /**157 * Sets the request accept header.158 * @param accept159 * @return160 */161 public SoapClientRequestActionBuilder accept(String accept) {162 soapMessage.header(SoapMessageHeaders.HTTP_ACCEPT, accept);163 return this;164 }165 166 public SoapClientRequestActionBuilder mtomEnabled(boolean mtomEnabled) {167 soapMessage.mtomEnabled(mtomEnabled);168 getAction().setMtomEnabled(mtomEnabled);169 return this;170 }171 @Override172 protected SendSoapMessageAction getAction() {173 return (SendSoapMessageAction) super.getAction();174 }175}...

Full Screen

Full Screen

SoapMessage

Using AI Code Generation

copy

Full Screen

1def soapClientRequestActionBuilder = new SoapClientRequestActionBuilder()2soapClientRequestActionBuilder.client("soapClient")3soapClientRequestActionBuilder.message()4soapClientRequestActionBuilder.soap()5soapClientRequestActionBuilder.body()6soapClientRequestActionBuilder.build()7def soapClientResponseActionBuilder = new SoapClientResponseActionBuilder()8soapClientResponseActionBuilder.client("soapClient")9soapClientResponseActionBuilder.message()10soapClientResponseActionBuilder.soap()11soapClientResponseActionBuilder.body()12soapClientResponseActionBuilder.build()13def soapServerRequestActionBuilder = new SoapServerRequestActionBuilder()14soapServerRequestActionBuilder.server("soapServer")15soapServerRequestActionBuilder.message()16soapServerRequestActionBuilder.soap()17soapServerRequestActionBuilder.body()18soapServerRequestActionBuilder.build()19def soapServerResponseActionBuilder = new SoapServerResponseActionBuilder()20soapServerResponseActionBuilder.server("soapServer")21soapServerResponseActionBuilder.message()22soapServerResponseActionBuilder.soap()23soapServerResponseActionBuilder.body()24soapServerResponseActionBuilder.build()25def soapActionBuilder = new SoapActionBuilder()

Full Screen

Full Screen

SoapMessage

Using AI Code Generation

copy

Full Screen

1context().soapMessage()2 .client("soapClient")3 .send()4 .soapAction("getOrder")5 "</ns0:getOrder>");6context().soapMessage()7 .client("soapClient")8 .receive()9 "<ns0:product>citrus:concat('SOAP ', citrus:randomNumber(3))</ns0:product>" +10 "</ns0:getOrderResponse>");11context().soapMessage()12 .server("soapServer")13 .receive()14 "</ns0:getOrder>");15context().soapMessage()16 .server("soapServer")17 .send()18 "<ns0:product>citrus:concat('SOAP ', citrus:randomNumber(3))</ns0:product>" +19 "</ns0:getOrderResponse>");

Full Screen

Full Screen

SoapMessage

Using AI Code Generation

copy

Full Screen

1soap()2 .client(soapClient)3 .send()4 .soapMessage(soapMessage)5 .header("operation", "sayHello")6 .header("citrus_soap_action", "sayHello")7 .payload(soapMessage);8soap()9 .client(soapClient)10 .send()11 .soapMessage(soapMessage)12 .header("operation", "sayHello")13 .header("citrus_soap_action", "sayHello")14 .payload(soapMessage);15soap()16 .client(soapClient)17 .send()18 .soapMessage(soapMessage)19 .header("operation", "sayHello")20 .header("citrus_soap_action", "sayHello")21 .payload(soapMessage);22soap()23 .client(soapClient)24 .send()25 .soapMessage(soapMessage)26 .header("operation", "sayHello")27 .header("citrus_soap_action", "sayHello")28 .payload(soapMessage);29soap()30 .client(soapClient)31 .send()32 .soapMessage(soapMessage)33 .header("operation", "sayHello")34 .header("citrus_soap_action", "sayHello")35 .payload(soapMessage);36soap()37 .client(soapClient)38 .send()39 .soapMessage(soapMessage)40 .header("operation", "sayHello")41 .header("citrus_soap_action", "sayHello")42 .payload(soapMessage);

Full Screen

Full Screen

SoapMessage

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.dsl.design.TestDesigner2import com.consol.citrus.dsl.design.TestDesigner3import com.consol.citrus.dsl.design.TestDesigner4import com.consol.citrus.dsl.design.TestDesigner5TestDesigner testDesigner = new TestDesigner()6testDesigner.soap()7 .client("soapClient")8 .send()9 .soapMessage()10 .header()11 .name("ns1:TestHeader")12 .value("TestHeader")13 .build()14 .body()15 .name("ns2:TestRequest")16 .value("<ns2:Message>Hello Citrus!</ns2:Message>")17 .build()18 .build()19testDesigner.soap()20 .client("soapClient")21 .send()22testDesigner.soap()23 .client("soapClient")24 .receive()25testDesigner.soap()26 .client("soapClient")27 .receive()28 .extractFromHeader("ns1:TestHeader", "testHeader")29 .extractFromPayload("ns2:TestResponse", "testResponse")30testDesigner.run()31println("Test header: " + testDesigner.getVariable("testHeader"))32println("Test response: " + testDesigner.getVariable("testResponse"))

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.

Run Citrus automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful