1 package de.spring.webservices.client;
3 import org.springframework.beans.factory.annotation.Autowired;
4 import org.springframework.ws.client.core.WebServiceTemplate;
6 import de.spring.webservices.auto.CustomBindingExampleRequest;
7 import de.spring.webservices.auto.CustomBindingExampleResponse;
8 import de.spring.webservices.auto.ExampleRequest;
9 import de.spring.webservices.auto.ExampleResponse;
10 //import de.spring.webservices.auto.Examples;
11 //import de.spring.webservices.auto.ExamplesService;
12 //import de.spring.webservices.auto.ParentEnumType;
15 * Someone could write code like this one in order to send and receive
16 * information from our Web Services.
19 public class ExampleClientService {
20 private final WebServiceTemplate webServiceTemplate;
23 public ExampleClientService(WebServiceTemplate webServiceTemplate) {
24 this.webServiceTemplate = webServiceTemplate;
27 // maven-jaxb2-plugin DOESN'T CREATE @WebService, @WebServiceClient y @WebEndpoint
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 // maven-jaxb2-plugin DOESN'T CREATE @WebService, @WebServiceClient y @WebEndpoint
49 // public CustomBindingExampleResponse sendAndReceiveJavaCustom() {
50 // final CustomBindingExampleRequest customBindingxampleRequest =
51 // new CustomBindingExampleRequest();
52 // customBindingxampleRequest.setData("CUSTOM BINDING JAVA. SCARLETT. IT IS CANON.");
53 // customBindingxampleRequest.setParentEnum(ParentEnumType.FIRST);
55 // final Examples exampleService = new ExamplesService().getExamplesSoap12();
56 // final CustomBindingExampleResponse customBindingExampleResponse =
57 // exampleService.customBindingExample(customBindingxampleRequest);
59 // return customBindingExampleResponse;
62 public CustomBindingExampleResponse sendAndReceiveSpringCustom() {
63 final CustomBindingExampleRequest customBindingxampleRequest =
64 new CustomBindingExampleRequest();
65 customBindingxampleRequest.setData("CUSTOM BINDING SPRING. SCARLETT. IT IS CANON.");
67 final CustomBindingExampleResponse customBindingExampleResponse =
68 (CustomBindingExampleResponse) this.webServiceTemplate
69 .marshalSendAndReceive(customBindingxampleRequest);
71 return customBindingExampleResponse;