use of javax.wsdl.extensions.ExtensionRegistry in project cxf by apache.
the class SoapBindingFactory method createSoapBinding.
private void createSoapBinding(final SoapBindingInfo bi) throws WSDLException {
boolean isSoap12 = bi.getSoapVersion() instanceof Soap12;
Bus bs = getBus();
WSDLManager m = bs.getExtension(WSDLManager.class);
ExtensionRegistry extensionRegistry = m.getExtensionRegistry();
SoapBinding soapBinding = SOAPBindingUtil.createSoapBinding(extensionRegistry, isSoap12);
soapBinding.setStyle(bi.getStyle());
soapBinding.setTransportURI(bi.getTransportURI());
bi.addExtensor(soapBinding);
for (BindingOperationInfo b : bi.getOperations()) {
for (BindingFaultInfo faultInfo : b.getFaults()) {
SoapFault soapFault = SOAPBindingUtil.createSoapFault(extensionRegistry, isSoap12);
soapFault.setUse("literal");
soapFault.setName(faultInfo.getFaultInfo().getFaultName().getLocalPart());
faultInfo.addExtensor(soapFault);
}
SoapOperationInfo soi = b.getExtensor(SoapOperationInfo.class);
SoapOperation soapOperation = SOAPBindingUtil.createSoapOperation(extensionRegistry, isSoap12);
soapOperation.setSoapActionURI(soi.getAction());
soapOperation.setStyle(soi.getStyle());
boolean isRpc = "rpc".equals(soapOperation.getStyle());
b.addExtensor(soapOperation);
if (b.getInput() != null) {
List<String> bodyParts = null;
List<SoapHeaderInfo> headerInfos = b.getInput().getExtensors(SoapHeaderInfo.class);
if (headerInfos != null && !headerInfos.isEmpty()) {
bodyParts = new ArrayList<>();
for (MessagePartInfo part : b.getInput().getMessageParts()) {
bodyParts.add(part.getName().getLocalPart());
}
for (SoapHeaderInfo headerInfo : headerInfos) {
SoapHeader soapHeader = SOAPBindingUtil.createSoapHeader(extensionRegistry, BindingInput.class, isSoap12);
soapHeader.setMessage(b.getInput().getMessageInfo().getName());
soapHeader.setPart(headerInfo.getPart().getName().getLocalPart());
soapHeader.setUse("literal");
bodyParts.remove(headerInfo.getPart().getName().getLocalPart());
headerInfo.getPart().setProperty(HEADER, true);
b.getInput().addExtensor(soapHeader);
}
}
SoapBody body = SOAPBindingUtil.createSoapBody(extensionRegistry, BindingInput.class, isSoap12);
body.setUse("literal");
if (isRpc) {
body.setNamespaceURI(b.getName().getNamespaceURI());
}
if (bodyParts != null) {
body.setParts(bodyParts);
}
b.getInput().addExtensor(body);
}
if (b.getOutput() != null) {
List<String> bodyParts = null;
List<SoapHeaderInfo> headerInfos = b.getOutput().getExtensors(SoapHeaderInfo.class);
if (headerInfos != null && !headerInfos.isEmpty()) {
bodyParts = new ArrayList<>();
for (MessagePartInfo part : b.getOutput().getMessageParts()) {
bodyParts.add(part.getName().getLocalPart());
}
for (SoapHeaderInfo headerInfo : headerInfos) {
SoapHeader soapHeader = SOAPBindingUtil.createSoapHeader(extensionRegistry, BindingOutput.class, isSoap12);
soapHeader.setMessage(b.getOutput().getMessageInfo().getName());
soapHeader.setPart(headerInfo.getPart().getName().getLocalPart());
soapHeader.setUse("literal");
bodyParts.remove(headerInfo.getPart().getName().getLocalPart());
b.getOutput().addExtensor(soapHeader);
}
}
SoapBody body = SOAPBindingUtil.createSoapBody(extensionRegistry, BindingOutput.class, isSoap12);
body.setUse("literal");
if (isRpc) {
body.setNamespaceURI(b.getName().getNamespaceURI());
}
if (bodyParts != null) {
body.setParts(bodyParts);
}
b.getOutput().addExtensor(body);
}
}
}
use of javax.wsdl.extensions.ExtensionRegistry in project cxf by apache.
the class SchemaFactoryImpl method newDefinition.
/**
* Create a new instance of a Definition, with an instance of a
* PopulatedExtensionRegistry as its ExtensionRegistry.
*/
public Definition newDefinition() {
Definition def = factory.newDefinition();
ExtensionRegistry extReg = newPopulatedExtensionRegistry();
def.setExtensionRegistry(extReg);
return def;
}
use of javax.wsdl.extensions.ExtensionRegistry in project cxf by apache.
the class WSDLCorbaFactoryImpl method newDefinition.
/**
* Create a new instance of a Definition, with an instance of a
* PopulatedExtensionRegistry as its ExtensionRegistry.
*/
public Definition newDefinition() {
Definition def = factory.newDefinition();
ExtensionRegistry extReg = newPopulatedExtensionRegistry();
def.setExtensionRegistry(extReg);
return def;
}
use of javax.wsdl.extensions.ExtensionRegistry in project tomee by apache.
the class CommonsSchemaLoader method readWsdl.
private Definition readWsdl(URI wsdlURI) throws OpenEJBException {
Definition definition;
WSDLFactory wsdlFactory;
try {
wsdlFactory = WSDLFactory.newInstance();
} catch (WSDLException e) {
throw new OpenEJBException("Could not create WSDLFactory", e);
}
WSDLReader wsdlReaderNoImport = wsdlFactory.newWSDLReader();
wsdlReaderNoImport.setFeature("javax.wsdl.importDocuments", false);
ExtensionRegistry extensionRegistry = new PopulatedExtensionRegistry();
extensionRegistry.mapExtensionTypes(Types.class, SchemaConstants.Q_ELEM_XSD_1999, UnknownExtensibilityElement.class);
extensionRegistry.registerDeserializer(Types.class, SchemaConstants.Q_ELEM_XSD_1999, extensionRegistry.getDefaultDeserializer());
extensionRegistry.registerSerializer(Types.class, SchemaConstants.Q_ELEM_XSD_1999, extensionRegistry.getDefaultSerializer());
extensionRegistry.mapExtensionTypes(Types.class, SchemaConstants.Q_ELEM_XSD_2000, UnknownExtensibilityElement.class);
extensionRegistry.registerDeserializer(Types.class, SchemaConstants.Q_ELEM_XSD_2000, extensionRegistry.getDefaultDeserializer());
extensionRegistry.registerSerializer(Types.class, SchemaConstants.Q_ELEM_XSD_2000, extensionRegistry.getDefaultSerializer());
extensionRegistry.mapExtensionTypes(Types.class, SchemaConstants.Q_ELEM_XSD_2001, UnknownExtensibilityElement.class);
extensionRegistry.registerDeserializer(Types.class, SchemaConstants.Q_ELEM_XSD_2001, extensionRegistry.getDefaultDeserializer());
extensionRegistry.registerSerializer(Types.class, SchemaConstants.Q_ELEM_XSD_2001, extensionRegistry.getDefaultSerializer());
wsdlReaderNoImport.setExtensionRegistry(extensionRegistry);
JarWSDLLocator wsdlLocator = new JarWSDLLocator(wsdlURI);
WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
Thread thread = Thread.currentThread();
ClassLoader oldCl = thread.getContextClassLoader();
thread.setContextClassLoader(this.getClass().getClassLoader());
try {
try {
definition = wsdlReader.readWSDL(wsdlLocator);
} catch (WSDLException e) {
throw new OpenEJBException("Failed to read wsdl document", e);
} catch (RuntimeException e) {
throw new OpenEJBException(e.getMessage(), e);
}
} finally {
thread.setContextClassLoader(oldCl);
}
return definition;
}
use of javax.wsdl.extensions.ExtensionRegistry 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