use of org.apache.cxf.service.model.DescriptionInfo in project cxf by apache.
the class WSDLServiceBuilder method buildBinding.
public BindingInfo buildBinding(ServiceInfo service, Binding binding) {
BindingInfo bi = null;
StringBuilder ns = new StringBuilder(100);
BindingFactory factory = WSDLServiceUtils.getBindingFactory(binding, bus, ns);
if (factory instanceof WSDLBindingFactory) {
WSDLBindingFactory wFactory = (WSDLBindingFactory) factory;
bi = wFactory.createBindingInfo(service, binding, ns.toString());
copyExtensors(bi, binding.getExtensibilityElements());
copyExtensionAttributes(bi, binding);
}
if (bi == null) {
boolean onlyExtensors = false;
if (factory instanceof AbstractBindingFactory) {
bi = ((AbstractBindingFactory) factory).createBindingInfo(service, ns.toString(), null);
onlyExtensors = true;
} else {
bi = new BindingInfo(service, ns.toString());
}
bi.setName(binding.getQName());
copyExtensors(bi, binding.getExtensibilityElements());
copyExtensionAttributes(bi, binding);
for (BindingOperation bop : cast(binding.getBindingOperations(), BindingOperation.class)) {
if (LOG.isLoggable(Level.FINER)) {
LOG.finer("binding operation name is " + bop.getName());
}
String inName = null;
String outName = null;
if (bop.getBindingInput() != null) {
inName = bop.getBindingInput().getName();
}
if (bop.getBindingOutput() != null) {
outName = bop.getBindingOutput().getName();
}
BindingOperationInfo bop2 = null;
if (onlyExtensors) {
bop2 = bi.getOperation(new QName(binding.getQName().getNamespaceURI(), bop.getName()));
} else {
bop2 = bi.buildOperation(new QName(binding.getQName().getNamespaceURI(), bop.getName()), inName, outName);
if (bop2 != null) {
bi.addOperation(bop2);
}
}
if (bop2 != null) {
copyExtensors(bop2, bop.getExtensibilityElements());
copyExtensionAttributes(bop2, bop);
if (bop.getBindingInput() != null) {
copyExtensors(bop2.getInput(), bop.getBindingInput().getExtensibilityElements());
copyExtensionAttributes(bop2.getInput(), bop.getBindingInput());
handleHeader(bop2.getInput());
}
if (bop.getBindingOutput() != null) {
copyExtensors(bop2.getOutput(), bop.getBindingOutput().getExtensibilityElements());
copyExtensionAttributes(bop2.getOutput(), bop.getBindingOutput());
handleHeader(bop2.getOutput());
}
for (BindingFault f : cast(bop.getBindingFaults().values(), BindingFault.class)) {
BindingFaultInfo bif = bop2.getFault(new QName(service.getTargetNamespace(), f.getName()));
copyExtensors(bif, bop.getBindingFault(f.getName()).getExtensibilityElements());
copyExtensionAttributes(bif, bop.getBindingFault(f.getName()));
}
}
}
}
service.addBinding(bi);
DescriptionInfo d = service.getDescription();
if (null != d) {
d.getDescribed().add(bi);
}
return bi;
}
use of org.apache.cxf.service.model.DescriptionInfo in project cxf by apache.
the class Wsdl11AttachmentPolicyProvider method getEffectivePolicy.
/**
* The effective policy for a specific WSDL message (input or output) is calculated
* in relation to a specific port, and includes the element policy of the wsdl:message
* element that defines the message's type merged with the element policy of the
* wsdl11:binding and wsdl11:portType message definitions that describe the message.
* For example, the effective policy of a specific input message for a specific port
* would be the (element policies of the) wsdl11:message element defining the message type,
* the wsdl11:portType/wsdl11:operation/wsdl11:input element and the corresponding
* wsdl11:binding/wsdl11:operation/wsdl11:input element for that message.
*
* @param bmi the BindingMessageInfo identifiying the message
* @return the effective policy
*/
public Policy getEffectivePolicy(BindingMessageInfo bmi, Message m) {
ServiceInfo si = bmi.getBindingOperation().getBinding().getService();
DescriptionInfo di = si.getDescription();
Policy p = getElementPolicy(bmi, false, di);
MessageInfo mi = bmi.getMessageInfo();
p = mergePolicies(p, getElementPolicy(mi, true, di));
Extensible ex = getMessageTypeInfo(mi.getName(), di);
p = mergePolicies(p, getElementPolicy(ex, false, di));
return p;
}
use of org.apache.cxf.service.model.DescriptionInfo in project cxf by apache.
the class Wsdl11AttachmentPolicyProvider method getEffectivePolicy.
/**
* The effective policy for a WSDL operation policy subject is calculated in relation to a
* specific port, and includes the element policy of the wsdl11:portType/wsdl11:operation
* element that defines the operation merged with that of the corresponding
* wsdl11:binding/wsdl11:operation element.
*
* @param bi the BindingOperationInfo identifying the operation in relation to a port
* @return the effective policy
*/
public Policy getEffectivePolicy(BindingOperationInfo bi, Message m) {
DescriptionInfo di = bi.getBinding().getDescription();
Policy p = getElementPolicy(bi, false, di);
p = mergePolicies(p, getElementPolicy(bi.getOperationInfo(), false, di));
return p;
}
use of org.apache.cxf.service.model.DescriptionInfo in project cxf by apache.
the class Wsdl11AttachmentPolicyProvider method getEffectivePolicy.
public Policy getEffectivePolicy(BindingFaultInfo bfi, Message m) {
ServiceInfo si = bfi.getBindingOperation().getBinding().getService();
DescriptionInfo di = si.getDescription();
Policy p = getElementPolicy(bfi, false, di);
FaultInfo fi = bfi.getFaultInfo();
p = mergePolicies(p, getElementPolicy(fi, true, di));
Extensible ex = getMessageTypeInfo(fi.getName(), di);
p = mergePolicies(p, getElementPolicy(ex, false, di));
return p;
}
use of org.apache.cxf.service.model.DescriptionInfo in project cxf by apache.
the class JaxWsEndpointImpl method buildWsdlExtensibilities.
private void buildWsdlExtensibilities(BindingInfo bindingInfo) {
Addressing addressing = getAddressing();
if (addressing != null) {
ExtensionRegistry extensionRegistry = getBus().getExtension(WSDLManager.class).getExtensionRegistry();
try {
ExtensibilityElement el = extensionRegistry.createExtension(javax.wsdl.Binding.class, JAXWSAConstants.WSAW_USINGADDRESSING_QNAME);
el.setRequired(addressing.required());
bindingInfo.addExtensor(el);
StringBuilder polRefId = new StringBuilder(bindingInfo.getName().getLocalPart());
polRefId.append("_WSAM_Addressing_Policy");
UnknownExtensibilityElement uel = new UnknownExtensibilityElement();
W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
writer.writeStartElement("wsp", "PolicyReference", URI_POLICY_NS);
writer.writeAttribute("URI", "#" + polRefId.toString());
writer.writeEndElement();
Element pr = writer.getDocument().getDocumentElement();
uel.setElement(pr);
uel.setElementType(DOMUtils.getElementQName(pr));
bindingInfo.addExtensor(uel);
writer = new W3CDOMStreamWriter();
writer.writeStartElement("wsp", "Policy", URI_POLICY_NS);
writer.writeAttribute("wsu", URI_WSU_NS, "Id", polRefId.toString());
writer.writeStartElement("wsam", "Addressing", JAXWSAConstants.NS_WSAM);
if (!addressing.required()) {
writer.writeAttribute("wsp", URI_POLICY_NS, "Optional", "true");
}
writer.writeStartElement("wsp", "Policy", URI_POLICY_NS);
String s = getAddressingRequirement(addressing);
if (s != null) {
writer.writeEmptyElement("wsam", s, JAXWSAConstants.NS_WSAM);
}
writer.writeEndElement();
writer.writeEndElement();
writer.writeEndElement();
pr = writer.getDocument().getDocumentElement();
uel = new UnknownExtensibilityElement();
uel.setElement(pr);
uel.setElementType(DOMUtils.getElementQName(pr));
if (bindingInfo.getService().getDescription() == null) {
DescriptionInfo description = new DescriptionInfo();
description.setName(bindingInfo.getService().getName());
bindingInfo.getService().setDescription(description);
}
bindingInfo.getService().getDescription().addExtensor(uel);
} catch (Exception e) {
// ignore
e.printStackTrace();
}
}
}
Aggregations