@Override
public void validate() throws DeploymentException {
try {
if (definition == null) {
if (wsdl == null) {
throw new DeploymentException("wsdl property must be set");
}
description = DomUtil.parse(wsdl.getInputStream());
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
WSDLReader reader = wsdlFactory.newWSDLReader();
reader.setFeature(Constants.FEATURE_VERBOSE, false);
definition = reader.readWSDL(wsdl.getURL().toString(),
description);
}
if (service == null) {
// looking for the servicename according to targetServiceName
// first
if (definition.getServices().containsKey(getTargetService())) {
service = getTargetService();
} else {
service = (QName) definition.getServices().keySet()
.iterator().next();
}
}
WSDLServiceFactory factory = new WSDLServiceFactory(getBus(),
definition, service);
Service cxfService = factory.create();
EndpointInfo ei = cxfService.getServiceInfos().iterator().next()
.getEndpoints().iterator().next();
for (ServiceInfo serviceInfo : cxfService.getServiceInfos()) {
if (serviceInfo.getName().equals(service)
&& getEndpoint() != null
&& serviceInfo.getEndpoint(new QName(
serviceInfo.getName().getNamespaceURI(), getEndpoint())) != null) {
ei = serviceInfo.getEndpoint(new QName(
serviceInfo.getName().getNamespaceURI(), getEndpoint()));
}
}
if (endpoint == null) {
endpoint = ei.getName().getLocalPart();
}
ei.getBinding().setProperty(
AbstractBindingFactory.DATABINDING_DISABLED, Boolean.TRUE);
cxfService.getInInterceptors().add(
new ReadHeadersInterceptor(getBus()));
cxfService.getInInterceptors().add(new MustUnderstandInterceptor());
cxfService.getInInterceptors().add(new AttachmentInInterceptor());
cxfService.getInInterceptors().add(new StaxInInterceptor());
cxfService.getInInterceptors().add(
new ReadHeadersInterceptor(getBus()));
cxfService.getInInterceptors().add(new JbiOperationInterceptor());
cxfService.getInInterceptors().add(new JbiInWsdl1Interceptor());
cxfService.getInInterceptors().add(new JbiInInterceptor());
cxfService.getInInterceptors().add(new JbiInvokerInterceptor());
cxfService.getInInterceptors().add(new JbiPostInvokerInterceptor());
cxfService.getInInterceptors().add(new OutgoingChainInterceptor());
cxfService.getOutInterceptors().add(new JbiOutWsdl1Interceptor());
cxfService.getOutInterceptors().add(new SoapActionOutInterceptor());
cxfService.getOutInterceptors().add(new AttachmentOutInterceptor());
cxfService.getOutInterceptors().add(new MtomCheckInterceptor(isMtomEnabled()));
cxfService.getOutInterceptors().add(new StaxOutInterceptor());
cxfService.getOutInterceptors().add(
new SoapPreProtocolOutInterceptor());
cxfService.getOutInterceptors().add(
new SoapOutInterceptor(getBus()));
cxfService.getOutFaultInterceptors().add(
new SoapOutInterceptor(getBus()));
ep = new EndpointImpl(getBus(), cxfService, ei);
getInInterceptors().addAll(getBus().getInInterceptors());
getInFaultInterceptors().addAll(getBus().getInFaultInterceptors());
getOutInterceptors().addAll(getBus().getOutInterceptors());
getOutFaultInterceptors()
.addAll(getBus().getOutFaultInterceptors());
cxfService.getInInterceptors().addAll(getInInterceptors());
cxfService.getInFaultInterceptors()
.addAll(getInFaultInterceptors());
cxfService.getOutInterceptors().addAll(getOutInterceptors());
cxfService.getOutFaultInterceptors().addAll(
getOutFaultInterceptors());
ep.getInInterceptors().addAll(getInInterceptors());
ep.getInFaultInterceptors().addAll(getInFaultInterceptors());
ep.getOutInterceptors().addAll(getOutInterceptors());
ep.getOutFaultInterceptors().addAll(getOutFaultInterceptors());
ep.getOutInterceptors().add(new SoapActionOutInterceptor());
ep.getOutInterceptors().add(new AttachmentOutInterceptor());
ep.getOutInterceptors().add(new StaxOutInterceptor());
ep.getOutInterceptors().add(new SoapOutInterceptor(getBus()));
cxfService.getInInterceptors().addAll(getBus().getInInterceptors());
cxfService.getInFaultInterceptors().addAll(
getBus().getInFaultInterceptors());
cxfService.getOutInterceptors().addAll(
getBus().getOutInterceptors());
cxfService.getOutFaultInterceptors().addAll(
getBus().getOutFaultInterceptors());
chain = new JbiChainInitiationObserver(ep, getBus());
server = new ServerImpl(getBus(), ep, null, chain);
super.validate();
} catch (DeploymentException e) {
throw e;
} catch (Exception e) {
throw new DeploymentException(e);
}
}