1 package de.spring.webservices.client;
 
   3 import org.springframework.beans.factory.annotation.Autowired;
 
   4 import org.springframework.stereotype.Service;
 
   5 import org.springframework.ws.client.core.WebServiceTemplate;
 
   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;
 
  16  * Someone could write code like this one in order to send and receive
 
  17  * information from our Web Services.
 
  20 @Service("exampleClientService")
 
  21 public class ExampleClientService {     
 
  22     private final WebServiceTemplate webServiceTemplate;
 
  25     public ExampleClientService(WebServiceTemplate webServiceTemplate) {
 
  26             this.webServiceTemplate = webServiceTemplate;
 
  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.");
 
  34 //        final Examples exampleService = new ExamplesService().getExamplesSoap12();
 
  35 //        final ExampleResponse exampleResponse = exampleService.example(exampleRequest);
 
  37 //        return exampleResponse;
 
  40         public ExampleResponse sendAndReceiveSpring() {
 
  41         final ExampleRequest exampleRequest = new ExampleRequest();
 
  42         exampleRequest.setData("SCARLETT SPRING. IT IS CANON.");
 
  44         final ExampleResponse exampleResponse = (ExampleResponse)
 
  45                 this.webServiceTemplate.marshalSendAndReceive(exampleRequest);
 
  47         return exampleResponse;
 
  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);
 
  57 //        final Examples exampleService = new ExamplesService().getExamplesSoap12();
 
  58 //        final CustomBindingExampleResponse customBindingExampleResponse =
 
  59 //                exampleService.customBindingExample(customBindingxampleRequest);
 
  61 //        return customBindingExampleResponse;
 
  64         public CustomBindingExampleResponse sendAndReceiveSpringCustom() {
 
  65         final CustomBindingExampleRequest customBindingxampleRequest =
 
  66                         new CustomBindingExampleRequest();
 
  67         customBindingxampleRequest.setData("CUSTOM BINDING SPRING. SCARLETT. IT IS CANON.");
 
  69         final CustomBindingExampleResponse customBindingExampleResponse =
 
  70                         (CustomBindingExampleResponse) this.webServiceTemplate
 
  71                         .marshalSendAndReceive(customBindingxampleRequest);
 
  73         return customBindingExampleResponse;