1 package de.spring.webservices.client;
3 import name.gumartinm.spring_ws.parent.ParentEnumType;
5 import org.springframework.beans.factory.annotation.Autowired;
6 import org.springframework.ws.client.core.WebServiceTemplate;
8 import de.spring.webservices.auto.CustomBindingExampleRequest;
9 import de.spring.webservices.auto.CustomBindingExampleResponse;
10 import de.spring.webservices.auto.ExampleRequest;
11 import de.spring.webservices.auto.ExampleResponse;
12 import de.spring.webservices.auto.Examples;
13 import de.spring.webservices.auto.ExamplesService;
16 * Someone could write code like this one in order to send and receive
17 * information from our Web Services.
20 public class ExampleClientService {
21 private final WebServiceTemplate webServiceTemplate;
24 public ExampleClientService(WebServiceTemplate webServiceTemplate) {
25 this.webServiceTemplate = webServiceTemplate;
28 public ExampleResponse sendAndReceiveJava() {
29 final ExampleRequest exampleRequest = new ExampleRequest();
30 exampleRequest.setData("SCARLETT JAVA. IT IS CANON.");
32 final Examples exampleService = new ExamplesService().getExamplesSoap12();
33 final ExampleResponse exampleResponse = exampleService.example(exampleRequest);
35 return exampleResponse;
38 public ExampleResponse sendAndReceiveSpring() {
39 final ExampleRequest exampleRequest = new ExampleRequest();
40 exampleRequest.setData("SCARLETT SPRING. IT IS CANON.");
42 final ExampleResponse exampleResponse = (ExampleResponse)
43 this.webServiceTemplate.marshalSendAndReceive(exampleRequest);
45 return exampleResponse;
48 public CustomBindingExampleResponse sendAndReceiveJavaCustom() {
49 final CustomBindingExampleRequest customBindingxampleRequest =
50 new CustomBindingExampleRequest();
51 customBindingxampleRequest.setData("CUSTOM BINDING JAVA. SCARLETT. IT IS CANON.");
52 customBindingxampleRequest.setParentEnum(ParentEnumType.FIRST);
54 final Examples exampleService = new ExamplesService().getExamplesSoap12();
55 final CustomBindingExampleResponse customBindingExampleResponse =
56 exampleService.customBindingExample(customBindingxampleRequest);
58 return customBindingExampleResponse;
61 public CustomBindingExampleResponse sendAndReceiveSpringCustom() {
62 final CustomBindingExampleRequest customBindingxampleRequest =
63 new CustomBindingExampleRequest();
64 customBindingxampleRequest.setData("CUSTOM BINDING SPRING. SCARLETT. IT IS CANON.");
66 final CustomBindingExampleResponse customBindingExampleResponse =
67 (CustomBindingExampleResponse) this.webServiceTemplate
68 .marshalSendAndReceive(customBindingxampleRequest);
70 return customBindingExampleResponse;