Class clazz = Class.forName("org.codehaus.xfire.jaxws.JAXWSServiceFactory"); Constructor ct = clazz.getDeclaredConstructor(new Class[] { TransportManager.class }); factory = (ObjectServiceFactory) ct.newInstance(new Object[] { xfire.getTransportManager() });
factory = new FixedJAXWSServiceFactory(xfire.getTransportManager());
    public static ObjectServiceFactory findServiceFactory(                        XFire xfire,                        Class serviceClass,                        String annotations,                         String typeMapping) throws Exception {        // jsr181 is synonymous to java5        if (annotations != null && AN_JSR181.equals(annotations)) {            annotations = AN_JAVA5;        }        // Determine annotations        WebAnnotations wa = null;        String selectedAnnotations = null;        if (annotations != null) {            selectedAnnotations = annotations;            if (!annotations.equals(AN_NONE)) {                wa = (WebAnnotations) knownAnnotations.get(annotations);                if (wa == null) {                    throw new Exception("Unrecognized annotations: " + annotations);                }            }        } else {            for (Iterator it = knownAnnotations.entrySet().iterator(); it.hasNext();) {                Map.Entry entry = (Map.Entry) it.next();                WebAnnotations w = (WebAnnotations) entry.getValue();                if (w.hasWebServiceAnnotation(serviceClass)) {                    selectedAnnotations = (String) entry.getKey();                    wa = w;                    break;                }            }        }        // Determine TypeMappingRegistry        TypeMappingRegistry tm = null;        String selectedTypeMapping = null;        if (typeMapping == null) {            selectedTypeMapping = (wa == null) ? TM_DEFAULT : TM_JAXB2;        } else {            selectedTypeMapping = typeMapping;        }        tm = (TypeMappingRegistry) knownTypeMappings.get(selectedTypeMapping);        if (tm == null) {            throw new Exception("Unrecognized typeMapping: " + typeMapping);        }        // Create factory        ObjectServiceFactory factory = null;        if (wa == null) {            factory = new ObjectServiceFactory(xfire.getTransportManager(),                                               new AegisBindingProvider(tm));        } else if (selectedAnnotations.equals(AN_JAVA5) &&                    selectedTypeMapping.equals(TM_JAXB2)) {            try {                Class clazz = Class.forName("org.codehaus.xfire.jaxws.JAXWSServiceFactory");                Constructor ct = clazz.getDeclaredConstructor(new Class[] { TransportManager.class });                factory = (ObjectServiceFactory) ct.newInstance(new Object[] { xfire.getTransportManager() });            } catch (Exception e) {                factory = new AnnotationServiceFactory(wa,                         xfire.getTransportManager(),                         new AegisBindingProvider(tm));            }        } else {            factory = new AnnotationServiceFactory(wa,                                                    xfire.getTransportManager(),                                                    new AegisBindingProvider(tm));        }        // Register only JBI transport in the factory        factory.getSoap11Transports().clear();        factory.getSoap12Transports().clear();        factory.getSoap11Transports().add(JbiTransport.JBI_BINDING);        return factory;    }