1    /****************************************************************************
2    * Copyright (c) 2005, 2006, 2007, 2008, 2009 Imola Informatica.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the LGPL License v2.1
5    * which accompanies this distribution, and is available at
6    * http://www.gnu.org/licenses/lgpl.html
7    ****************************************************************************/
8   package it.imolinfo.jbi4corba.test.cxf;
9   
10  import it.imolinfo.jbi4corba.jbi.cxf.CXFUtils;
11  import it.imolinfo.jbi4corba.jbi.cxf.Jbi4CorbaBareOutInterceptor;
12  import it.imolinfo.jbi4corba.jbi.cxf.Jbi4CorbaConsumerExceptionInterceptor;
13  import it.imolinfo.jbi4corba.jbi.cxf.Jbi4CorbaWrappedOutInterceptor;
14  import it.imolinfo.jbi4corba.jbi.processor.transform.SourceTransformer;
15  import it.imolinfo.jbi4corba.jbi.processor.transform.StringSource;
16  import it.imolinfo.jbi4corba.test.webservice.generator.testclasses.TestEchoBean;
17  import it.imolinfo.jbi4corba.test.webservice.generator.testclasses.TestUserProfile;
18  import it.imolinfo.jbi4corba.test.webservice.generator.testclasses.TestUserProfileConsumer;
19  import it.imolinfo.jbi4corba.test.webservice.generator.testclasses.UserProfileException;
20  import it.imolinfo.jbi4corba.webservice.runtime.ProviderServiceInvoker;
21  
22  import java.io.ByteArrayInputStream;
23  import java.io.ByteArrayOutputStream;
24  import java.io.File;
25  import java.io.IOException;
26  import java.io.InputStream;
27  import java.io.OutputStream;
28  import java.lang.reflect.Method;
29  import java.util.ArrayList;
30  import java.util.List;
31  import java.util.ResourceBundle;
32  
33  import javax.xml.namespace.QName;
34  import javax.xml.stream.XMLStreamException;
35  import javax.xml.stream.XMLStreamReader;
36  import javax.xml.transform.Source;
37  import javax.xml.transform.Transformer;
38  import javax.xml.transform.TransformerConfigurationException;
39  import javax.xml.transform.TransformerException;
40  import javax.xml.transform.TransformerFactory;
41  import javax.xml.transform.dom.DOMSource;
42  import javax.xml.transform.stream.StreamResult;
43  
44  import junit.framework.TestCase;
45  
46  import org.apache.cxf.binding.soap.SoapBindingConstants;
47  import org.apache.cxf.binding.soap.interceptor.RPCOutInterceptor;
48  import org.apache.cxf.endpoint.Endpoint;
49  import org.apache.cxf.frontend.MethodDispatcher;
50  import org.apache.cxf.helpers.DOMUtils;
51  import org.apache.cxf.interceptor.BareInInterceptor;
52  import org.apache.cxf.interceptor.Fault;
53  import org.apache.cxf.interceptor.StaxInInterceptor;
54  import org.apache.cxf.interceptor.StaxOutInterceptor;
55  import org.apache.cxf.interceptor.WrappedInInterceptor;
56  import org.apache.cxf.jaxws.JAXWSMethodDispatcher;
57  import org.apache.cxf.jaxws.JaxWsClientFactoryBean;
58  import org.apache.cxf.jaxws.interceptors.HolderInInterceptor;
59  import org.apache.cxf.jaxws.interceptors.HolderOutInterceptor;
60  import org.apache.cxf.jaxws.interceptors.WrapperClassInInterceptor;
61  import org.apache.cxf.jaxws.interceptors.WrapperClassOutInterceptor;
62  import org.apache.cxf.message.Exchange;
63  import org.apache.cxf.message.ExchangeImpl;
64  import org.apache.cxf.message.Message;
65  import org.apache.cxf.message.MessageImpl;
66  import org.apache.cxf.phase.PhaseInterceptorChain;
67  import org.apache.cxf.phase.PhaseManager;
68  import org.apache.cxf.service.Service;
69  import org.apache.cxf.service.model.BindingOperationInfo;
70  import org.apache.cxf.service.model.EndpointInfo;
71  import org.apache.cxf.service.model.MessageInfo;
72  import org.apache.cxf.service.model.MessagePartInfo;
73  import org.apache.cxf.staxutils.FragmentStreamReader;
74  import org.apache.cxf.staxutils.StaxUtils;
75  import org.w3c.dom.Document;
76  import org.w3c.dom.Element;
77  
78  
79  /**
80   * Test class for the Provider using CXF. The test, from the extended WSDL, creates the service and invokes-it
81   * @author marco 
82   */
83  public class CXFConsumerTest extends TestCase {      
84  
85      public static final String wsdlDirExt = "src/test/etc/wsdlext"; 
86      
87      public static final String serviceUnitName = "testServiceUnit";
88      
89      public static final String rootPath = "target/test-wsdl-ext";
90      
91      public static final String workingPath = "target/test-wsdl-ext/temp";
92      
93      private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory.newInstance();
94      
95      public void setUp() {
96          File dir = new File(rootPath);        
97          dir.mkdir();
98          File dirTemp = new File(workingPath);
99          dirTemp.mkdir();
100     }
101     
102     
103     /**
104      * Consumer test with simple parameters.
105      */
106     public void testSimpleEcho() {
107         // String wsdlName = "EchoCXFTest.wsdl";
108         QName interfaceName = new QName("urn:it.jb4corba.userprofile", "EchoOperations");
109         
110         Method methodCalled = null;
111         try {
112             methodCalled = TestEchoBean.class.getMethod("echo", String.class);            
113         } catch (SecurityException e) {
114             e.printStackTrace();
115             fail(e.getMessage());
116         } catch (NoSuchMethodException e) {
117             e.printStackTrace();
118             fail(e.getMessage());
119         }
120         
121         // Adds the parameters
122         List params = new ArrayList();
123         params.add("testConsumer");
124         
125         // Creates the service
126         Endpoint  ep = serviceCreation(interfaceName, new TestEchoBean());
127         
128         String jbiXmlRequest = fromObjectToXML(ep, methodCalled, params);
129         System.out.println("xmlMessage:" + jbiXmlRequest);
130         
131         // Here put the JBI Call...returning:
132         
133         String jbiXmlExpected = "<ns1:echoResponse xmlns:ns1=\"http://testclasses.generator.webservice.test.jbi4corba.imolinfo.it/\">"+
134         "<return>test</return></ns1:echoResponse>";
135                           
136         Object returnedObj = fromXMLToObject(ep, jbiXmlExpected, methodCalled);
137         System.out.println("Returned: " + returnedObj);            
138         assertEquals("test", returnedObj);
139     }
140     
141     
142     /**
143      * Consumer test with complex parameters.
144      */
145     public void testUserProfile() {
146                                                
147         QName interfaceName = new QName("http://testclasses.generator.webservice.test.jbi4corba.imolinfo.it/", "UserProfileConsumerCorbaInterfaceOperations");
148         
149         Method methodCalled = null;
150         try {
151             methodCalled = TestUserProfile.class.getMethod("getUserProfile", String.class);            
152         } catch (SecurityException e) {
153             e.printStackTrace();
154             fail(e.getMessage());
155         } catch (NoSuchMethodException e) {
156             e.printStackTrace();
157             fail(e.getMessage());
158         }
159         
160         // Adds the parameters
161         List params = new ArrayList();
162         params.add("testConsumerGetUserProfile");
163         
164         // Creates the service
165         Endpoint  ep = serviceCreation(interfaceName, new TestUserProfileConsumer());
166         
167         String jbiXmlRequest = fromObjectToXML(ep, methodCalled, params);
168         
169         System.out.println("xmlMessage produced:" + jbiXmlRequest);
170         /*
171         // Here put the JBI Call...returning:
172         
173         String jbiXmlExpected = "<ns1:getUserProfileResponse xmlns:ns1=\"http://testclasses.generator.webservice.test.jbi4corba.imolinfo.it/\">" +
174         		"<return xmlns=\"http://testclasses.generator.webservice.test.jbi4corba.imolinfo.it/\"><address>via Selice</address><age>31</age><name>Marco</name></return></ns1:getUserProfileResponse>";
175                           
176 
177         Object returnedObj = fromXMLToObject(ep, jbiXmlExpected, methodCalled);
178         System.out.println("Returned: " + returnedObj);
179         UserProfile userProf = (UserProfile)returnedObj;
180         System.out.println("Name: " + userProf.getName());
181         System.out.println("Address: " + userProf.getAddress());
182         System.out.println("Age: " + userProf.getAge());
183         assertEquals(userProf.getName(), "Marco");
184         assertEquals(userProf.getAddress(), "via Selice");
185         assertEquals(userProf.getAge(), 31);
186         */
187     }    
188     
189     /**
190      * Consumer test with complex Fault.
191      */
192     public void _testUserProfileFault() {
193                                                
194         QName interfaceName = new QName("http://testclasses.generator.webservice.test.jbi4corba.imolinfo.it/", "UserProfileConsumerCorbaInterfaceOperations");
195         
196         Method methodCalled = null;
197         try {
198             methodCalled = TestUserProfile.class.getMethod("getUserProfile", String.class);            
199         } catch (SecurityException e) {
200             e.printStackTrace();
201             fail(e.getMessage());
202         } catch (NoSuchMethodException e) {
203             e.printStackTrace();
204             fail(e.getMessage());
205         }
206         
207         // Adds the parameters
208         List params = new ArrayList();
209         params.add("testConsumerGetUserProfile");
210         
211         // Creates the service
212         Endpoint  ep = serviceCreation(interfaceName, new TestUserProfileConsumer());
213         
214         String jbiXmlRequest = fromObjectToXML(ep, methodCalled, params);
215         System.out.println("xmlMessage:" + jbiXmlRequest);
216         
217         // Here put the JBI Call...returning:
218         
219 //        String jbiXmlExpected =
220 //            "<detail><ns1:UserProfileException xmlns:ns1=\"http://testclasses.generator.webservice.test.jbi4corba.imolinfo.it/\">" +
221 //            "<reason xmlns:ns2=\"http://testclasses.generator.webservice.test.jbi4corba.imolinfo.it/\">myreason</reason>"+
222 //            "<userCode xmlns:ns2=\"http://testclasses.generator.webservice.test.jbi4corba.imolinfo.it/\">myuserCode</userCode>" +
223 //        "<profiles xmlns:ns2=\"http://testclasses.generator.webservice.test.jbi4corba.imolinfo.it/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
224 //        "xsi:type=\"ns2:userProfileArray\"><item><ns2:address>via vai</ns2:address><ns2:age>23</ns2:age><ns2:name>Marco</ns2:name></item></profiles>" +
225 //            "</ns1:UserProfileException>" + 
226 //            "</detail>";
227         
228         String jbiXmlExpected =
229             "<ns1:UserProfileException xmlns:ns1=\"http://testclasses.generator.webservice.test.jbi4corba.imolinfo.it/\">" +
230             "<reason xmlns:ns2=\"http://testclasses.generator.webservice.test.jbi4corba.imolinfo.it/\">myreason</reason>"+
231             "<userCode xmlns:ns2=\"http://testclasses.generator.webservice.test.jbi4corba.imolinfo.it/\">myuserCode</userCode>" +
232         "<profiles xmlns:ns2=\"http://testclasses.generator.webservice.test.jbi4corba.imolinfo.it/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
233         "xsi:type=\"ns2:userProfileArray\"><item><ns2:address>via vai</ns2:address><ns2:age>23</ns2:age><ns2:name>Marco</ns2:name></item></profiles>" +
234             "</ns1:UserProfileException>" + 
235             "";        
236                                    
237         // FAULT Path 
238         Throwable returnedObj = fromXMLToException(ep, jbiXmlExpected, methodCalled);
239         // Object returnedObj = fromXMLToObject(ep, jbiXmlExpected, methodCalled);
240         
241         System.out.println("Returned: " + returnedObj.getClass().getName());        
242         UserProfileException userProfEx = (UserProfileException)returnedObj;
243         System.out.println("UserCode: " + userProfEx.getUserCode());
244         System.out.println("Reason: " + userProfEx.getReason());
245         System.out.println("USerProfile: " + userProfEx.getProfiles()[0]);      
246         assertEquals(userProfEx.getProfiles()[0].getName(), "Marco");
247         assertEquals(userProfEx.getProfiles()[0].getAge(), 23);
248         assertEquals(userProfEx.getProfiles()[0].getAddress(), "via vai");              
249     }       
250     
251     /**
252      * Converts the method call in an XML message
253      * @param ep
254      * @param methodCalled
255      * @param params
256      * @return
257      */
258     public String fromObjectToXML(Endpoint ep, Method methodCalled, List params) {
259     
260         // Gets the BindingOperationInfo from the method
261         JAXWSMethodDispatcher md = (JAXWSMethodDispatcher) 
262         ep.getService().get(MethodDispatcher.class.getName());        
263         BindingOperationInfo bio = md.getBindingOperation(methodCalled, ep);        
264         String parameterStyle = getParameterStyle(bio);
265         String bindingStyle = getBindingStyle(bio);
266         QName operation = bio.getOperationInfo().getName();
267         System.out.println("operation to call:" + operation);           
268 
269         // Creates the message
270         Message message = new MessageImpl();
271         Exchange exchange = new ExchangeImpl();                                    
272         exchange.setOneWay(false);
273         exchange.put(BindingOperationInfo.class, bio);
274         exchange.put(Service.class, ep.getService());            
275         exchange.put(Endpoint.class, ep);            
276         message.setExchange(exchange);            
277         exchange.setOutMessage(message);                  
278         exchange.put(StaxOutInterceptor.FORCE_START_DOCUMENT, Boolean.TRUE);
279       
280         // We have to map the request (input operation).
281         message.put(Message.REQUESTOR_ROLE, Boolean.TRUE);        
282        
283         // Sets the in content
284         message.setContent(List.class, params);
285                       
286         // Sets the output stream 
287         OutputStream out = new ByteArrayOutputStream();        
288         message.setContent(OutputStream.class, out);
289                 
290         
291         // The interceptor order is important! First the Stream is created, than the message converted in xml
292         // and then is wrapped. Notice that with a custom binding, we could fix the interceptor execution order statically        
293         PhaseInterceptorChain outInterceptorChain = new PhaseInterceptorChain(CXFUtils.getBus().getExtension(PhaseManager.class).getOutPhases());
294         CXFUtils.populateOutInterceptors(outInterceptorChain, parameterStyle, bindingStyle, true);                       
295         // Process the message
296         message.setInterceptorChain(outInterceptorChain);
297         outInterceptorChain.doIntercept(message);
298                 
299         return out.toString();
300     }
301     
302     
303     /**
304      * Converts the method call in an XML message
305      * @param ep
306      * @param methodCalled
307      * @param params
308      * @return
309      */
310     public Object fromXMLToObject(Endpoint ep, String xml, Method methodCalled) {
311     
312         // Gets the BindingOperationInfo from the method
313         JAXWSMethodDispatcher md = (JAXWSMethodDispatcher) 
314         ep.getService().get(MethodDispatcher.class.getName());       
315         BindingOperationInfo bio = md.getBindingOperation(methodCalled, ep);  
316         String parameterStyle = getParameterStyle(bio);
317         String bindingStyle = getBindingStyle(bio);
318         
319         QName operation = bio.getOperationInfo().getName();
320         System.out.println("operation to call:" + operation); 
321         // System.out.println(bio.getOperationInfo().getOutput().getMessagePartByIndex(0).getName());
322                           
323         // Creates the message
324         Message message = new MessageImpl();
325         Exchange exchange = new ExchangeImpl();                                    
326         exchange.setOneWay(false);
327         exchange.put(BindingOperationInfo.class, bio);
328         exchange.put(Service.class, ep.getService());            
329         exchange.put(Endpoint.class, ep);            
330         message.setExchange(exchange);            
331         
332         exchange.setOutMessage(message);
333         
334         // Important! If not set, maps the object in the input message (the opposite as the objectToXml method)..
335         message.put(Message.REQUESTOR_ROLE, Boolean.TRUE);        
336                                    
337         // Sets the Source as In message
338         try {
339             message.setContent(InputStream.class, convertMessageToInputStream(new StringSource(xml)));
340         } catch (TransformerConfigurationException e) {
341             e.printStackTrace();
342             fail(e.getMessage());
343         } catch (IOException e) {
344             e.printStackTrace();
345             fail(e.getMessage());
346         } catch (TransformerException e) {
347             e.printStackTrace();
348             fail(e.getMessage());
349         }
350                 
351         // The interceptor order is important! First the Stream is created, than the message is unwrapped and then 
352         // converted into objects. Notice that with a custom binding, we could fix the interceptor execution order statically
353         PhaseInterceptorChain inInterceptorChain = new PhaseInterceptorChain(CXFUtils.getBus().getExtension(PhaseManager.class).getInPhases());
354 
355         
356         message.setInterceptorChain(inInterceptorChain);                    
357         
358         this.populateInInterceptors(inInterceptorChain, parameterStyle, bindingStyle);
359                                  
360         // Process the message
361         inInterceptorChain.doIntercept(message);
362 
363         // Gets the returned objects
364         List outObjs = (List)message.getContent(List.class);        
365         
366         return outObjs.get(0);
367     }
368     
369     /**
370      * Converts the method call in an XML message
371      * @param ep
372      * @param methodCalled
373      * @param params
374      * @return
375      */
376     public Throwable fromXMLToException(Endpoint ep, String xml, Method methodCalled) {                
377     
378         // Gets the BindingOperationInfo from the method
379         JAXWSMethodDispatcher md = (JAXWSMethodDispatcher) 
380         ep.getService().get(MethodDispatcher.class.getName());       
381         BindingOperationInfo bio = md.getBindingOperation(methodCalled, ep);  
382         String parameterStyle = getParameterStyle(bio);
383         
384         QName operation = bio.getOperationInfo().getName();
385         System.out.println("operation to call:" + operation); 
386         // System.out.println(bio.getOperationInfo().getOutput().getMessagePartByIndex(0).getName());
387                           
388         // Creates the message
389         Message message = new MessageImpl();
390         Exchange exchange = new ExchangeImpl();                                    
391         exchange.setOneWay(false);
392         exchange.put(BindingOperationInfo.class, bio);
393         exchange.put(Service.class, ep.getService());            
394         exchange.put(Endpoint.class, ep);            
395         message.setExchange(exchange);            
396         exchange.setInMessage(message);
397         exchange.setOutMessage(new MessageImpl());
398 
399         
400                 
401         // Preapres the CXF fault to be processed
402         // Mandatory to pass a message...
403         String msg =  "ERROR_IN_JBI_PROCESSING";
404         Fault fault = new Fault(new org.apache.cxf.common.i18n.Message(msg, (ResourceBundle) null));
405                                 
406         StringSource bodySource = new StringSource(xml);
407         XMLStreamReader xmlReader = StaxUtils.createXMLStreamReader(bodySource);
408         Element detailContent = null;
409         try {
410             detailContent = StaxUtils.read(new FragmentStreamReader(xmlReader)).getDocumentElement();
411         } catch (XMLStreamException e) {
412             e.printStackTrace();
413             fail(e.getMessage());
414         }
415                 
416         Document detailDocument = DOMUtils.createDocument();
417         Element detail = detailDocument.createElement("detail");
418         detailDocument.adoptNode(detailContent);
419         detail.appendChild(detailContent);
420                       
421         fault.setDetail(detail);
422         
423         SourceTransformer sourceTransformer = new SourceTransformer();
424         String xmlException;
425         try {
426             xmlException = sourceTransformer.toString(new DOMSource(detail));
427             System.err.println("xmlException: " + xmlException);
428         } catch (TransformerException e) {
429             // TODO Auto-generated catch block
430             e.printStackTrace();
431         }               
432                        
433         // Sets the fault on the message
434         message.setContent(Exception.class, fault);
435                                       
436         // Handle the message using the ClientFaultConverter;
437         PhaseInterceptorChain faultInterceptorChain = new PhaseInterceptorChain(CXFUtils.getBus().getExtension(PhaseManager.class).getInPhases());
438         message.setInterceptorChain(faultInterceptorChain);     
439         //faultInterceptorChain.add(new StaxOutInterceptor());
440         //faultInterceptorChain.add(new FaultOutInterceptor());	
441         faultInterceptorChain.add(new Jbi4CorbaConsumerExceptionInterceptor());
442                                
443         // Process the message
444         faultInterceptorChain.doIntercept(message);       
445 
446         // The ClientFaultConverter replaces the fault with the Exception object in the message for the exception class...
447         Throwable th = message.getContent(Exception.class);
448         // Gets the returned objects
449         // Throwable th = fault.getCause();     
450            
451         return th;
452     }
453     
454     
455 
456       
457     /**
458      * Creates the service.
459      * @param interfaceName
460      * @param fakeServant
461      * @return
462      */
463     public Endpoint serviceCreation(QName interfaceName, Object fakeServant) {       
464                
465         try {       
466             // Creates the service from the service interface.       
467             JaxWsClientFactoryBean factory = CXFUtils.getJaxWsClientFactoryBean();    
468             factory.setServiceClass(fakeServant.getClass());               
469             factory.create();
470             
471             // Gets the service model
472             Service service = factory.getServiceFactory().getService();
473                         
474             // Sets the invoker
475             service.setInvoker(new ProviderServiceInvoker(null));
476             ((ProviderServiceInvoker)service.getInvoker()).setServiceObject(fakeServant);
477                                   
478             // Gets the CXF Endpoint
479             EndpointInfo ei = CXFUtils.getEndpointInfo(service);              
480             Endpoint ep = CXFUtils.getEndpoint(service, ei);
481             
482             ByteArrayOutputStream baos = new ByteArrayOutputStream();        
483             CXFUtils.writeDefinitionOnOutputStream(service, baos);        
484             System.err.println(baos.toString());                         
485             
486             return ep;
487  
488         } catch (Exception e) {
489             e.printStackTrace();
490             fail(e.getMessage());
491             return null;
492         } finally {
493             deleteDir(new File(rootPath));
494             deleteDir(new File(workingPath));            
495         }
496         
497     }        
498     
499     private static InputStream convertMessageToInputStream(Source src) throws IOException,
500     TransformerConfigurationException, TransformerException {
501 
502         final Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
503 
504         ByteArrayOutputStream baos = new ByteArrayOutputStream();
505         StreamResult result = new StreamResult(baos);
506         transformer.transform(src, result);
507 
508         return new ByteArrayInputStream(baos.toByteArray());
509     }    
510        
511     /**
512      * recursively removes all the directory
513      * @param dir
514      * @return
515      */
516     public static boolean deleteDir(File dir) {
517         if (dir.isDirectory()) {
518             String[] children = dir.list();
519             for (int i=0; i<children.length; i++) {
520                 boolean success = deleteDir(new File(dir, children[i]));
521                 if (!success) {
522                     return false;
523                 }
524             }
525         }    
526         // The directory is now empty so delete it
527         return dir.delete();
528     }  
529     
530     /**
531      * Return the correct parameter style for the binding, Wrapped or Bare 
532      * (notice that the WSDL is always Document/literal).
533      * @param bio
534      * @return <code>SoapBindingConstants.PARAMETER_STYLE_WRAPPED</code> or <code>SoapBindingConstants.PARAMETER_STYLE_BARE</code>
535      */
536     private static String getParameterStyle(BindingOperationInfo bio) {
537             
538         String parameterStyle = SoapBindingConstants.PARAMETER_STYLE_WRAPPED;
539         if (bio!= null) {
540             if (bio.getUnwrappedOperation() == null) {
541                 parameterStyle = SoapBindingConstants.PARAMETER_STYLE_BARE;
542             }
543         }        
544         return parameterStyle;
545     }
546     
547     /**
548      * This method creates the CXF OUT Interceptors chain and process the message.
549      * 
550      * @param parameterStyle
551      * @param message
552      */
553   	private void populateOutInterceptors(PhaseInterceptorChain outInterceptorChain, 
554   			String parameterStyle, String bindingStyle) {
555   		
556         outInterceptorChain.add(new StaxOutInterceptor());
557         
558         outInterceptorChain.add(new HolderOutInterceptor());
559         // For Jax-ws
560         outInterceptorChain.add(new WrapperClassOutInterceptor());  
561         
562   		// RPC  vs Document
563   		if (bindingStyle.equals(SoapBindingConstants.BINDING_STYLE_RPC)) {
564   			outInterceptorChain.add(new RPCOutInterceptor());
565   		} else if (SoapBindingConstants.BINDING_STYLE_DOC.equalsIgnoreCase(bindingStyle)
566                 && SoapBindingConstants.PARAMETER_STYLE_BARE.equalsIgnoreCase(parameterStyle)) {            
567             outInterceptorChain.add(new Jbi4CorbaBareOutInterceptor()); 
568   		} else {            
569   			// Wrapped
570   		    outInterceptorChain.add(new Jbi4CorbaWrappedOutInterceptor());
571   		    outInterceptorChain.add(new Jbi4CorbaBareOutInterceptor());
572   		} 	
573   	} 
574 	
575     /**
576      * This method creates the CXF OUT Interceptors chain and process the message.
577      * 
578      * @param parameterStyle
579      * @param message
580      */
581 	private void populateInInterceptors(PhaseInterceptorChain inInterceptorChain, 
582 			String parameterStyle, String bindingStyle) {
583 		
584 		  inInterceptorChain.add(new StaxInInterceptor());        
585 			inInterceptorChain.add(new WrapperClassInInterceptor());			
586 			
587 			inInterceptorChain.add(new HolderInInterceptor());
588 	      
589 	      if (parameterStyle.equals(SoapBindingConstants.PARAMETER_STYLE_WRAPPED)) {
590 	          inInterceptorChain.add(new WrappedInInterceptor());
591 	      }
592 	      inInterceptorChain.add(new BareInInterceptor());
593        
594 	} 	
595 	
596     /**
597      * Return the correct binding style for the binding, Document o RPC.
598      * We don'thave  SOAP binding extensions, so we have to calculate that 
599      * from the message part. See Section 7 of the SOAP 1.1 specification.
600      * (notice that the WSDL is always Document/literal).
601      * @param bio
602      * @return <code>SoapBindingConstants.PARAMETER_STYLE_WRAPPED</code> or <code>SoapBindingConstants.PARAMETER_STYLE_BARE</code>
603      */
604     private static String getBindingStyle(BindingOperationInfo bio) {                	
605         String bindingStyle = SoapBindingConstants.BINDING_STYLE_DOC;     
606         if (bio.getOperationInfo() != null) {
607            MessageInfo mi = bio.getOperationInfo().getInput();
608             MessagePartInfo mpi = mi.getMessagePart(0);
609             // There
610             if ((mi.getMessageParts().size() != 1)  || 
611             	(!mpi.isElement()) ) {
612             	bindingStyle = SoapBindingConstants.BINDING_STYLE_RPC;        	
613             } 
614         }
615         return bindingStyle;
616     }   
617             
618 }