interfaceName = wsdlPortType.getQName();
} else if (!interfaceName.equals(wsdlPortType.getQName())) {
throw new IllegalArgumentException("The name of the PortType defined by the deployed wsdl does not match the interface name of the jbi endpoint");
}
// Create the DOM document
definition = new WSDLFlattener(definition).getDefinition(interfaceName);
description = WSDLFactory.newInstance().newWSDLWriter().getDocument(definition);
}
String svcLocalName = (service != null) ? service.getLocalPart() : null;
String svcNamespace;
if (interfaceName != null) {
svcNamespace = interfaceName.getNamespaceURI();
} else if (service != null) {
svcNamespace = service.getNamespaceURI();
} else {
svcNamespace = null;
}
Map props = new HashMap();
props.put(ObjectServiceFactory.PORT_TYPE, interfaceName);
if (style != null) {
props.put(ObjectServiceFactory.STYLE, style);
}
props.put(ObjectServiceFactory.USE, SoapConstants.USE_LITERAL);
if (serviceInterface != null) {
props.put(AnnotationServiceFactory.ALLOW_INTERFACE, Boolean.TRUE);
}
if (properties != null) {
props.putAll(properties);
}
xfireService = factory.create(serviceClass, svcLocalName, svcNamespace, props);
xfireService.setInvoker(new BeanInvoker(getPojo()));
xfireService.setFaultSerializer(new JbiFaultSerializer());
xfireService.setProperty(SoapConstants.MTOM_ENABLED, Boolean.toString(mtomEnabled));
xfire.getServiceRegistry().register(xfireService);
// If the wsdl has not been provided,
// generate one
if (this.description == null) {
this.description = generateWsdl();
// Check service name and endpoint name
QName serviceName = xfireService.getName();
QName interfName = xfireService.getServiceInfo().getPortType();
String endpointName = null;
if (service == null) {
service = serviceName;
} else if (!service.equals(serviceName)) {
logger.warn("The service name defined in the wsdl (" + serviceName +
") does not match the service name defined in the endpoint spec (" + service +
"). WSDL description may be unusable.");
}
if (interfaceName == null) {
interfaceName = interfName;
} else if (!interfaceName.equals(interfName)) {
logger.warn("The interface name defined in the wsdl (" + interfName +
") does not match the service name defined in the endpoint spec (" + interfaceName +
"). WSDL description may be unusable.");
}
// Parse the WSDL
WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
reader.setFeature(Constants.FEATURE_VERBOSE, false);
definition = reader.readWSDL(null, description);
javax.wsdl.Service svc = definition.getService(serviceName);
if (svc != null) {
if (svc.getPorts().values().size() == 1) {
Port port = (Port) svc.getPorts().values().iterator().next();
// Check if this is the same as defined in endpoint spec
endpointName = port.getName();
if (endpoint == null) {
endpoint = endpointName;
} else if (!endpoint.equals(endpointName)) {
// Override generated WSDL
port.setName(endpoint);
description = WSDLFactory.newInstance().newWSDLWriter().getDocument(definition);
}
}
}
if (endpoint == null) {
throw new IllegalArgumentException("endpoint name should be provided");
}
// Flatten it
definition = new WSDLFlattener(definition).getDefinition(interfaceName);
description = WSDLFactory.newInstance().newWSDLWriter().getDocument(definition);
// Write WSDL
if (logger.isDebugEnabled()) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();