View Javadoc

    1   package org.codehaus.xfire.xmlbeans;
    2
    3   import java.lang.reflect.Method;
    4
    5   import javax.xml.namespace.QName;
    6
    7   import org.apache.xmlbeans.XmlBeans;
    8   import org.apache.xmlbeans.XmlObject;
    9   import org.codehaus.xfire.aegis.AegisBindingProvider;
    10  import org.codehaus.xfire.service.Service;
    11  import org.codehaus.xfire.service.binding.ObjectServiceFactory;
    12  import org.codehaus.xfire.soap.SoapConstants;
    13  import org.codehaus.xfire.transport.TransportManager;
    14
    15  /***
    16   * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
    17   */
    18  public class XmlBeansServiceFactory
    19          extends ObjectServiceFactory
    20  {
    21      public XmlBeansServiceFactory()
    22      {
    23          setStyle(SoapConstants.STYLE_DOCUMENT);
    24          setWsdlBuilderFactory(new XmlBeansWSDLBuilderFactory());
    25      }
    26
    27      public XmlBeansServiceFactory(TransportManager transportManager)
    28      {
    29          super(transportManager);
    30
    31          AegisBindingProvider provider = new AegisBindingProvider(new XmlBeansTypeRegistry());
    32          setBindingProvider(provider);
    33
    34          setStyle(SoapConstants.STYLE_DOCUMENT);
    35          setWsdlBuilderFactory(new XmlBeansWSDLBuilderFactory());
    36      }
    37
    38      protected QName getInParameterName(Service service, Method method, int paramNumber, boolean doc)
    39      {
    40          Class[] paramClasses = method.getParameterTypes();
    41          if (XmlObject.class.isAssignableFrom(paramClasses[paramNumber]))
    42          {
    43              return XmlBeans.typeForClass(paramClasses[paramNumber]).getDocumentElementName();
    44          }
    45          else
    46          {
    47              return super.getInParameterName(service, method, paramNumber, doc);
    48          }
    49      }
    50
    51      protected QName getOutParameterName(Service service, Method method, boolean doc)
    52      {
    53          if (XmlObject.class.isAssignableFrom(method.getReturnType()))
    54          {
    55              return XmlBeans.typeForClass(method.getReturnType()).getDocumentElementName();
    56          }
    57          else
    58          {
    59              return super.getOutParameterName(service, method, doc);
    60          }
    61      }
    62  }