1
2
3
4
5
6
7
8 package it.imolinfo.jbi4corba.webservice.runtime;
9
10 import it.imolinfo.jbi4corba.Logger;
11 import it.imolinfo.jbi4corba.LoggerFactory;
12 import it.imolinfo.jbi4corba.exception.Jbi4CorbaException;
13 import it.imolinfo.jbi4corba.jbi.cxf.CXFUtils;
14 import it.imolinfo.jbi4corba.webservice.descriptor.ProviderServiceDescriptor;
15
16 import java.io.ByteArrayOutputStream;
17 import java.io.IOException;
18
19 import javax.wsdl.WSDLException;
20 import javax.xml.namespace.QName;
21
22 import org.apache.cxf.jaxws.JaxWsClientFactoryBean;
23 import org.apache.cxf.service.Service;
24
25
26
27
28 public class ProviderServiceCreator {
29
30
31 private static final Logger LOG
32 = LoggerFactory.getLogger(ProviderServiceCreator.class);
33
34
35
36 public ProviderServiceCreator() {
37
38 }
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 public Service createService(ProviderServiceDescriptor serviceDescriptor, QName interfaceName) throws IOException, WSDLException,
54 Jbi4CorbaException {
55
56 LOG.debug(">>>>> createService - begin");
57 LOG.debug("InterfaceName: " + interfaceName);
58 LOG.debug("Service Interface: " + serviceDescriptor.getServiceInterface());
59
60
61 JaxWsClientFactoryBean endpointFactory = CXFUtils.getJaxWsClientFactoryBean();
62
63
64
65
66
67 endpointFactory.getServiceFactory().setAnonymousWrapperTypes(true);
68
69 endpointFactory.getServiceFactory().setQualifyWrapperSchema(true);
70 endpointFactory.getServiceFactory().setWrapped(true);
71
72
73 endpointFactory.setServiceClass(serviceDescriptor.getServiceInterface());
74 endpointFactory.setServiceName(interfaceName);
75
76
77 endpointFactory.create();
78
79
80 Service service = endpointFactory.getServiceFactory().getService();
81
82 LOG.debug("service: " + service);
83 LOG.debug("service.getName(): " + service.getName());
84
85 LOG.debug("Found services: " + service.getServiceInfos().size());
86 if (LOG.isDebugEnabled()) {
87 LOG.debug("Service=" + service);
88 }
89
90
91 service.setInvoker(new ProviderServiceInvoker(serviceDescriptor));
92
93 if (LOG.isDebugEnabled()) {
94 ByteArrayOutputStream baos = new ByteArrayOutputStream();
95 CXFUtils.writeDefinitionOnOutputStream(service, baos);
96 LOG.debug(baos.toString());
97 }
98
99 LOG.debug("<<<<< createService - end");
100 return service;
101 }
102
103
104
105
106
107
108
109
110
111
112
113
114 public Service createService(ProviderServiceDescriptor serviceDescriptor) throws IOException,
115 WSDLException, Jbi4CorbaException {
116 return createService(serviceDescriptor, null);
117 }
118
119 }