use of org.apache.cxf.service.model.DescriptionInfo in project cxf by apache.
the class WSDLServiceBuilder method buildMockServices.
public List<ServiceInfo> buildMockServices(Definition d) {
List<ServiceInfo> serviceList = new ArrayList<>();
List<Definition> defList = new ArrayList<>();
defList.add(d);
parseImports(d, defList);
for (Definition def : defList) {
for (Iterator<?> ite = def.getPortTypes().entrySet().iterator(); ite.hasNext(); ) {
Entry<?, ?> entry = (Entry<?, ?>) ite.next();
PortType portType = def.getPortType((QName) entry.getKey());
ServiceInfo serviceInfo = this.buildMockService(def, portType);
serviceList.add(serviceInfo);
for (Iterator<?> it2 = d.getAllBindings().values().iterator(); it2.hasNext(); ) {
Binding b = (Binding) it2.next();
if (b.getPortType() == portType) {
this.buildBinding(serviceInfo, b);
break;
}
}
}
if (def.getPortTypes().isEmpty()) {
DescriptionInfo description = new DescriptionInfo();
if (recordOriginal) {
description.setProperty(WSDL_DEFINITION, def);
}
description.setName(def.getQName());
description.setBaseURI(def.getDocumentBaseURI());
copyExtensors(description, def.getExtensibilityElements());
copyExtensionAttributes(description, def);
ServiceInfo service = new ServiceInfo();
service.setDescription(description);
if (recordOriginal) {
service.setProperty(WSDL_DEFINITION, def);
}
getSchemas(def, service);
service.setProperty(WSDL_SCHEMA_ELEMENT_LIST, this.schemaList);
serviceList.add(service);
}
}
return serviceList;
}
use of org.apache.cxf.service.model.DescriptionInfo in project cxf by apache.
the class WSDLServiceBuilder method buildServices.
private List<ServiceInfo> buildServices(Definition def, Service serv, QName endpointName, DescriptionInfo d) {
Map<QName, ServiceInfo> services = new LinkedHashMap<QName, ServiceInfo>();
DescriptionInfo description = d;
if (null == description) {
description = new DescriptionInfo();
if (recordOriginal) {
description.setProperty(WSDL_DEFINITION, def);
}
description.setName(def.getQName());
description.setBaseURI(def.getDocumentBaseURI());
copyExtensors(description, def.getExtensibilityElements());
copyExtensionAttributes(description, def);
Set<Definition> done = new HashSet<>();
done.add(def);
Collection<List<Import>> values = CastUtils.cast(def.getImports().values());
for (List<Import> imports : values) {
for (Import imp : imports) {
if (!done.contains(imp.getDefinition())) {
done.add(imp.getDefinition());
copyExtensors(description, imp.getExtensibilityElements());
copyExtensionAttributes(description, imp);
copyExtensors(description, imp.getDefinition().getExtensibilityElements());
copyExtensionAttributes(description, imp.getDefinition());
}
}
}
}
for (Port port : cast(serv.getPorts().values(), Port.class)) {
if (endpointName != null && !endpointName.getLocalPart().equals(port.getName())) {
continue;
}
Binding binding = port.getBinding();
PortType bindingPt = binding.getPortType();
if (bindingPt == null) {
org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("BINDING_MISSING_TYPE", LOG, binding.getQName());
throw new WSDLRuntimeException(msg);
}
// TODO: wsdl4j's bug. if there is recursive import,
// wsdl4j can not get operation input message
PortType pt = def.getPortType(bindingPt.getQName());
if (pt == null) {
pt = bindingPt;
}
ServiceInfo service = services.get(pt.getQName());
if (service == null) {
service = new ServiceInfo();
service.setDescription(description);
description.getDescribed().add(service);
if (recordOriginal) {
service.setProperty(WSDL_DEFINITION, def);
service.setProperty(WSDL_SERVICE, serv);
}
getSchemas(def, service);
copyDocumentation(service, serv);
service.setProperty(WSDL_SCHEMA_ELEMENT_LIST, this.schemaList);
service.setTargetNamespace(def.getTargetNamespace());
service.setName(serv.getQName());
copyExtensors(service, serv.getExtensibilityElements());
copyExtensionAttributes(service, serv);
buildInterface(service, pt);
services.put(pt.getQName(), service);
}
BindingInfo bi = service.getBinding(binding.getQName());
if (bi == null) {
bi = buildBinding(service, binding);
}
buildEndpoint(service, bi, port);
}
return new ArrayList<>(services.values());
}
use of org.apache.cxf.service.model.DescriptionInfo in project cxf by apache.
the class WSDLServiceBuilder method buildInterface.
public void buildInterface(ServiceInfo si, PortType p) {
InterfaceInfo inf = si.createInterface(p.getQName());
DescriptionInfo d = si.getDescription();
if (null != d) {
d.getDescribed().add(inf);
}
copyDocumentation(inf, p);
this.copyExtensors(inf, p.getExtensibilityElements());
this.copyExtensionAttributes(inf, p);
if (recordOriginal) {
inf.setProperty(WSDL_PORTTYPE, p);
}
for (Operation op : cast(p.getOperations(), Operation.class)) {
buildInterfaceOperation(inf, op);
}
}
use of org.apache.cxf.service.model.DescriptionInfo in project cxf by apache.
the class ServiceModelPolicyUpdater method addPolicy.
private void addPolicy(PolicyAttachment pa) {
// TODO - do I need to defensively copy this?
Element policyEl = pa.getElement();
UnknownExtensibilityElement uee = new UnknownExtensibilityElement();
uee.setRequired(true);
uee.setElementType(DOMUtils.getElementQName(policyEl));
uee.setElement(policyEl);
if (ei.getService().getDescription() == null) {
DescriptionInfo description = new DescriptionInfo();
description.setName(ei.getService().getName());
if (!StringUtils.isEmpty(ei.getAddress())) {
description.setBaseURI(ei.getAddress() + "?wsdl");
}
ei.getService().setDescription(description);
}
ei.getService().getDescription().addExtensor(uee);
}
use of org.apache.cxf.service.model.DescriptionInfo in project cxf by apache.
the class WSPolicyFeature method initializeEndpointPolicy.
private Policy initializeEndpointPolicy(Endpoint endpoint, Bus bus) {
initialize(bus);
DescriptionInfo i = endpoint.getEndpointInfo().getDescription();
Collection<Policy> loadedPolicies = null;
if (policyElements != null || policyReferenceElements != null) {
loadedPolicies = new ArrayList<>();
PolicyBuilder builder = bus.getExtension(PolicyBuilder.class);
if (null != policyElements) {
for (Element e : policyElements) {
loadedPolicies.add(builder.getPolicy(e));
}
}
if (null != policyReferenceElements) {
for (Element e : policyReferenceElements) {
PolicyReference pr = builder.getPolicyReference(e);
Policy resolved = resolveReference(pr, builder, bus, i);
if (null != resolved) {
loadedPolicies.add(resolved);
}
}
}
}
Policy thePolicy = new Policy();
if (policies != null) {
for (Policy p : policies) {
thePolicy = thePolicy.merge(p);
}
}
if (loadedPolicies != null) {
for (Policy p : loadedPolicies) {
thePolicy = thePolicy.merge(p);
}
}
return thePolicy;
}
Aggregations