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.stereotype.Service;
7 import org.springframework.ws.client.core.WebServiceTemplate;
9 import de.spring.webservices.client.auto.CustomBindingExampleFault;
10 import de.spring.webservices.client.auto.CustomBindingExampleRequest;
11 import de.spring.webservices.client.auto.CustomBindingExampleResponse;
12 import de.spring.webservices.client.auto.ExampleFault;
13 import de.spring.webservices.client.auto.ExampleRequest;
14 import de.spring.webservices.client.auto.ExampleResponse;
15 import de.spring.webservices.client.auto.Examples;
16 import de.spring.webservices.client.auto.ExamplesService;
19 * Someone could write code like this one in order to send and receive
20 * information from our Web Services.
23 @Service("exampleClientService")
24 public class ExampleClientService {
25 private final WebServiceTemplate webServiceTemplate;
28 public ExampleClientService(WebServiceTemplate webServiceTemplate) {
29 this.webServiceTemplate = webServiceTemplate;
32 public ExampleResponse sendAndReceiveJava() throws ExampleFault {
33 final ExampleRequest exampleRequest = new ExampleRequest();
34 exampleRequest.setData("SCARLETT JAVA. IT IS CANON.");
36 final Examples exampleService = new ExamplesService().getExamplesSoap12();
37 final ExampleResponse exampleResponse = exampleService.example(exampleRequest);
39 return exampleResponse;
42 public ExampleResponse sendAndReceiveSpring() {
43 final ExampleRequest exampleRequest = new ExampleRequest();
44 exampleRequest.setData("SCARLETT SPRING. IT IS CANON.");
46 final ExampleResponse exampleResponse = (ExampleResponse)
47 this.webServiceTemplate.marshalSendAndReceive(exampleRequest);
49 return exampleResponse;
52 public CustomBindingExampleResponse sendAndReceiveJavaCustom() throws CustomBindingExampleFault {
53 final CustomBindingExampleRequest customBindingxampleRequest =
54 new CustomBindingExampleRequest();
55 customBindingxampleRequest.setData("CUSTOM BINDING JAVA. SCARLETT. IT IS CANON.");
56 customBindingxampleRequest.setParentEnum(ParentEnumType.FIRST);
58 final Examples exampleService = new ExamplesService().getExamplesSoap12();
59 final CustomBindingExampleResponse customBindingExampleResponse =
60 exampleService.customBindingExample(customBindingxampleRequest);
62 return customBindingExampleResponse;
65 public CustomBindingExampleResponse sendAndReceiveSpringCustom() {
66 final CustomBindingExampleRequest customBindingxampleRequest =
67 new CustomBindingExampleRequest();
68 customBindingxampleRequest.setData("CUSTOM BINDING SPRING. SCARLETT. IT IS CANON.");
70 final CustomBindingExampleResponse customBindingExampleResponse =
71 (CustomBindingExampleResponse) this.webServiceTemplate
72 .marshalSendAndReceive(customBindingxampleRequest);
74 return customBindingExampleResponse;