df603dff0cae288880e19af46ac455257c2383c1
[SpringWebServicesForFun/.git] /
1 package de.spring.webservices.client;
2
3 import org.springframework.beans.factory.annotation.Autowired;
4 import org.springframework.ws.client.core.WebServiceTemplate;
5
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;
13
14 /**
15  * Someone could write code like this one in order to send and receive
16  * information from our Web Services.
17  * 
18  */
19 public class ExampleClientService {     
20     private final WebServiceTemplate webServiceTemplate;
21
22     @Autowired
23     public ExampleClientService(WebServiceTemplate webServiceTemplate) {
24             this.webServiceTemplate = webServiceTemplate;
25     }
26
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.");
31 //
32 //        final Examples exampleService = new ExamplesService().getExamplesSoap12();
33 //        final ExampleResponse exampleResponse = exampleService.example(exampleRequest);
34 //        
35 //        return exampleResponse;
36 //    }
37     
38         public ExampleResponse sendAndReceiveSpring() {
39         final ExampleRequest exampleRequest = new ExampleRequest();
40         exampleRequest.setData("SCARLETT SPRING. IT IS CANON.");
41
42         final ExampleResponse exampleResponse = (ExampleResponse)
43                 this.webServiceTemplate.marshalSendAndReceive(exampleRequest);
44         
45         return exampleResponse;
46     }
47         
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);
54 //  
55 //        final Examples exampleService = new ExamplesService().getExamplesSoap12();
56 //        final CustomBindingExampleResponse customBindingExampleResponse =
57 //                exampleService.customBindingExample(customBindingxampleRequest);
58 //        
59 //        return customBindingExampleResponse;
60 //    }
61         
62         public CustomBindingExampleResponse sendAndReceiveSpringCustom() {
63         final CustomBindingExampleRequest customBindingxampleRequest =
64                         new CustomBindingExampleRequest();
65         customBindingxampleRequest.setData("CUSTOM BINDING SPRING. SCARLETT. IT IS CANON.");
66
67         final CustomBindingExampleResponse customBindingExampleResponse =
68                         (CustomBindingExampleResponse) this.webServiceTemplate
69                         .marshalSendAndReceive(customBindingxampleRequest);
70         
71         return customBindingExampleResponse;
72     }
73 }