use of org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader in project cxf by apache.
the class HeaderUtil method getHeaderQNames.
private static Set<QName> getHeaderQNames(BindingMessageInfo bmi) {
Set<QName> set = new HashSet<>();
List<MessagePartInfo> mps = bmi.getMessageInfo().getMessageParts();
List<ExtensibilityElement> extList = bmi.getExtensors(ExtensibilityElement.class);
if (extList != null) {
for (ExtensibilityElement ext : extList) {
if (SOAPBindingUtil.isSOAPHeader(ext)) {
SoapHeader header = SOAPBindingUtil.getSoapHeader(ext);
String pn = header.getPart();
for (MessagePartInfo mpi : mps) {
if (pn.equals(mpi.getName().getLocalPart())) {
if (mpi.isElement()) {
set.add(mpi.getElementQName());
} else {
set.add(mpi.getTypeQName());
}
break;
}
}
}
}
}
return set;
}
use of org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader in project cxf by apache.
the class SOAPBindingUtil method getBindingOutputSOAPHeaders.
public static List<SoapHeader> getBindingOutputSOAPHeaders(BindingOperation bop) {
List<SoapHeader> headers = new ArrayList<>();
BindingOutput bindingOutput = bop.getBindingOutput();
if (bindingOutput != null) {
for (Object obj : bindingOutput.getExtensibilityElements()) {
if (isSOAPHeader(obj)) {
headers.add(getProxy(SoapHeader.class, obj));
}
}
}
return headers;
}
use of org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader in project cxf by apache.
the class SOAPBindingUtil method getBindingInputSOAPHeaders.
public static List<SoapHeader> getBindingInputSOAPHeaders(BindingOperation bop) {
List<SoapHeader> headers = new ArrayList<>();
BindingInput bindingInput = bop.getBindingInput();
if (bindingInput != null) {
for (Object obj : bindingInput.getExtensibilityElements()) {
if (isSOAPHeader(obj)) {
headers.add(getProxy(SoapHeader.class, obj));
}
}
}
return headers;
}
use of org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader in project cxf by apache.
the class SoapBindingFactory method addMessageFromBinding.
protected void addMessageFromBinding(ExtensibilityElement ext, BindingOperationInfo bop, boolean isInput) {
SoapHeader header = SOAPBindingUtil.getSoapHeader(ext);
ServiceInfo serviceInfo = bop.getBinding().getService();
if (header != null && header.getMessage() == null) {
throw new RuntimeException("Problem with WSDL: soap:header element" + " for operation " + bop.getName() + " under binding " + bop.getBinding().getName() + " does not contain a valid message attribute.");
}
if (header != null && serviceInfo.getMessage(header.getMessage()) == null) {
Definition def = (Definition) serviceInfo.getProperty(WSDLServiceBuilder.WSDL_DEFINITION);
SchemaCollection schemas = serviceInfo.getXmlSchemaCollection();
if (def != null && schemas != null) {
QName qn = header.getMessage();
javax.wsdl.Message msg = findMessage(qn, def);
if (msg != null) {
addOutOfBandParts(bop, msg, schemas, isInput, header.getPart());
serviceInfo.refresh();
} else {
throw new RuntimeException("Problem with WSDL: soap:header element" + " for operation " + bop.getName() + " is referring to an undefined wsdl:message element: " + qn);
}
}
}
}
use of org.apache.cxf.binding.soap.wsdl.extensions.SoapHeader 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);
}
}
}
Aggregations