f8bad467d6b7b398d6aa1f11e8ccccdbbc9f0ccf
[SpringWebServicesForFun/.git] /
1 package de.spring.webservices.client;
2
3 import org.springframework.beans.factory.annotation.Autowired;
4 import org.springframework.stereotype.Service;
5 import org.springframework.ws.client.core.WebServiceTemplate;
6
7 import de.spring.webservices.client.auto.CustomBindingExampleRequest;
8 import de.spring.webservices.client.auto.CustomBindingExampleResponse;
9 import de.spring.webservices.client.auto.ExampleRequest;
10 import de.spring.webservices.client.auto.ExampleResponse;
11 //import de.spring.webservices.client.auto.Examples;
12 //import de.spring.webservices.client.auto.ExamplesService;
13 //import de.spring.webservices.client.auto.ParentEnumType;
14
15 /**
16  * Someone could write code like this one in order to send and receive
17  * information from our Web Services.
18  * 
19  */
20 @Service("exampleClientService")
21 public class ExampleClientService {     
22     private final WebServiceTemplate webServiceTemplate;
23
24     @Autowired
25     public ExampleClientService(WebServiceTemplate webServiceTemplate) {
26             this.webServiceTemplate = webServiceTemplate;
27     }
28
29 //  maven-jaxb2-plugin DOESN'T CREATE @WebService, @WebServiceClient y @WebEndpoint
30 //      public ExampleResponse sendAndReceiveJava() {
31 //        final ExampleRequest exampleRequest = new ExampleRequest();
32 //        exampleRequest.setData("SCARLETT JAVA. IT IS CANON.");
33 //
34 //        final Examples exampleService = new ExamplesService().getExamplesSoap12();
35 //        final ExampleResponse exampleResponse = exampleService.example(exampleRequest);
36 //        
37 //        return exampleResponse;
38 //    }
39     
40         public ExampleResponse sendAndReceiveSpring() {
41         final ExampleRequest exampleRequest = new ExampleRequest();
42         exampleRequest.setData("SCARLETT SPRING. IT IS CANON.");
43
44         final ExampleResponse exampleResponse = (ExampleResponse)
45                 this.webServiceTemplate.marshalSendAndReceive(exampleRequest);
46         
47         return exampleResponse;
48     }
49         
50 //  maven-jaxb2-plugin DOESN'T CREATE @WebService, @WebServiceClient y @WebEndpoint
51 //      public CustomBindingExampleResponse sendAndReceiveJavaCustom() {
52 //        final CustomBindingExampleRequest customBindingxampleRequest =
53 //                      new CustomBindingExampleRequest();
54 //        customBindingxampleRequest.setData("CUSTOM BINDING JAVA. SCARLETT. IT IS CANON.");
55 //        customBindingxampleRequest.setParentEnum(ParentEnumType.FIRST);
56 //  
57 //        final Examples exampleService = new ExamplesService().getExamplesSoap12();
58 //        final CustomBindingExampleResponse customBindingExampleResponse =
59 //                exampleService.customBindingExample(customBindingxampleRequest);
60 //        
61 //        return customBindingExampleResponse;
62 //    }
63         
64         public CustomBindingExampleResponse sendAndReceiveSpringCustom() {
65         final CustomBindingExampleRequest customBindingxampleRequest =
66                         new CustomBindingExampleRequest();
67         customBindingxampleRequest.setData("CUSTOM BINDING SPRING. SCARLETT. IT IS CANON.");
68
69         final CustomBindingExampleResponse customBindingExampleResponse =
70                         (CustomBindingExampleResponse) this.webServiceTemplate
71                         .marshalSendAndReceive(customBindingxampleRequest);
72         
73         return customBindingExampleResponse;
74     }
75 }