use of javax.wsdl.extensions.mime.MIMEMultipartRelated in project cxf by apache.
the class WSIBPValidator method getIgnorableParts.
private static Set<String> getIgnorableParts(WSDLElement ext) {
Set<String> parts = null;
if (ext != null && ext.getExtensibilityElements() != null && ext.getExtensibilityElements().size() > 0 && ext.getExtensibilityElements().get(0) instanceof MIMEMultipartRelated) {
MIMEMultipartRelated mpr = (MIMEMultipartRelated) ext.getExtensibilityElements().get(0);
List<MIMEPart> mps = CastUtils.cast(mpr.getMIMEParts());
parts = new HashSet<>(mps.size());
for (Iterator<MIMEPart> it = mps.iterator(); it.hasNext(); ) {
MIMEPart mp = it.next();
if (mp.getExtensibilityElements() != null && mp.getExtensibilityElements().size() > 0 && mp.getExtensibilityElements().get(0) instanceof MIMEContent) {
parts.add(((MIMEContent) mp.getExtensibilityElements().get(0)).getPart());
}
}
}
return parts;
}
use of javax.wsdl.extensions.mime.MIMEMultipartRelated in project cxf by apache.
the class SoapBindingFactory method initializeMessage.
private void initializeMessage(SoapBindingInfo bi, BindingOperationInfo boi, BindingMessageInfo bmsg) {
MessageInfo msg = bmsg.getMessageInfo();
List<MessagePartInfo> messageParts = new ArrayList<>();
messageParts.addAll(msg.getMessageParts());
List<SoapHeader> headers = SOAPBindingUtil.getSoapHeaders(bmsg.getExtensors(ExtensibilityElement.class));
if (headers != null) {
for (SoapHeader header : headers) {
SoapHeaderInfo headerInfo = new SoapHeaderInfo();
headerInfo.setUse(header.getUse());
if (StringUtils.isEmpty(header.getPart())) {
throw new RuntimeException("Problem with WSDL: soap:header element in operation " + boi.getName().getLocalPart() + " does not specify a part.");
}
MessagePartInfo part = msg.getMessagePart(new QName(msg.getName().getNamespaceURI(), header.getPart()));
if (part != null && header.getMessage() != null && !part.getMessageInfo().getName().equals(header.getMessage())) {
part = null;
// out of band, let's find it
for (MessagePartInfo mpi : msg.getOutOfBandParts()) {
if (mpi.getName().getLocalPart().equals(header.getPart()) && mpi.getMessageInfo().getName().equals(header.getMessage())) {
part = mpi;
}
}
}
if (part != null) {
headerInfo.setPart(part);
messageParts.remove(part);
bmsg.addExtensor(headerInfo);
}
}
// Exclude the header parts from the message part list.
bmsg.setMessageParts(messageParts);
}
SoapBodyInfo bodyInfo = new SoapBodyInfo();
SoapBody soapBody = SOAPBindingUtil.getSoapBody(bmsg.getExtensors(ExtensibilityElement.class));
List<?> parts = null;
if (soapBody == null) {
MIMEMultipartRelated mmr = bmsg.getExtensor(MIMEMultipartRelated.class);
if (mmr != null) {
parts = mmr.getMIMEParts();
}
} else {
bmsg.addExtensor(soapBody);
bodyInfo.setUse(soapBody.getUse());
parts = soapBody.getParts();
}
// Initialize the body parts.
List<MessagePartInfo> attParts = null;
if (parts != null) {
List<MessagePartInfo> bodyParts = new ArrayList<>();
for (Iterator<?> itr = parts.iterator(); itr.hasNext(); ) {
Object part = itr.next();
if (part instanceof MIMEPart) {
MIMEPart mpart = (MIMEPart) part;
attParts = handleMimePart(mpart, attParts, msg, bmsg, bodyParts, messageParts);
} else {
addSoapBodyPart(msg, bodyParts, (String) part);
}
}
bodyInfo.setParts(bodyParts);
bodyInfo.setAttachments(attParts);
} else {
bodyInfo.setParts(messageParts);
}
bmsg.addExtensor(bodyInfo);
}
use of javax.wsdl.extensions.mime.MIMEMultipartRelated in project cxf by apache.
the class ServiceProcessor method processParameter.
private void processParameter(JavaMethod jm, BindingOperationInfo operation) throws ToolException {
// process input
List<ExtensibilityElement> inbindings = null;
if (operation.getInput() != null) {
inbindings = operation.getInput().getExtensors(ExtensibilityElement.class);
}
if (inbindings == null) {
inbindings = new ArrayList<>();
}
String use = null;
for (ExtensibilityElement ext : inbindings) {
if (SOAPBindingUtil.isSOAPBody(ext)) {
SoapBody soapBody = SOAPBindingUtil.getSoapBody(ext);
use = soapBody.getUse();
} else if (SOAPBindingUtil.isSOAPHeader(ext)) {
processSoapHeader(jm, operation, ext);
}
if (ext instanceof MIMEMultipartRelated && jm.enableMime()) {
processMultipart(jm, operation, (MIMEMultipartRelated) ext, JavaType.Style.IN);
}
}
// process output
if (operation.getOutput() != null) {
List<ExtensibilityElement> outbindings = operation.getOutput().getExtensors(ExtensibilityElement.class);
if (outbindings == null) {
outbindings = new ArrayList<>();
}
for (ExtensibilityElement ext : outbindings) {
if (SOAPBindingUtil.isSOAPHeader(ext)) {
SoapHeader soapHeader = SOAPBindingUtil.getSoapHeader(ext);
if (isOutOfBandHeader(operation.getOutput(), ext)) {
continue;
}
boolean found = false;
for (JavaParameter parameter : jm.getParameters()) {
if (soapHeader.getPart().equals(parameter.getPartName())) {
setParameterAsHeader(parameter);
found = true;
}
}
if (jm.getReturn().getName() != null && jm.getReturn().getName().equals(soapHeader.getPart())) {
found = true;
}
if (Boolean.valueOf((String) context.get(ToolConstants.CFG_EXTRA_SOAPHEADER)) && !found) {
// Header can't be found in java method parameters, in
// different message
// other than messages used in porttype operation
ParameterProcessor processor = new ParameterProcessor(context);
MessagePartInfo exPart = service.getMessage(soapHeader.getMessage()).getMessagePart(new QName(soapHeader.getMessage().getNamespaceURI(), soapHeader.getPart()));
JavaParameter jp = processor.addParameterFromBinding(jm, exPart, JavaType.Style.OUT);
setParameterAsHeader(jp);
}
}
if (ext instanceof MIMEMultipartRelated && jm.enableMime()) {
processMultipart(jm, operation, (MIMEMultipartRelated) ext, JavaType.Style.OUT);
}
}
}
jm.setSoapUse(SOAPBindingUtil.getSoapUse(use));
if (javax.jws.soap.SOAPBinding.Style.RPC == jm.getSoapStyle() && javax.jws.soap.SOAPBinding.Use.ENCODED == jm.getSoapUse()) {
System.err.println("** Unsupported RPC-Encoded Style Use **");
}
if (javax.jws.soap.SOAPBinding.Style.RPC == jm.getSoapStyle() && javax.jws.soap.SOAPBinding.Use.LITERAL == jm.getSoapUse()) {
return;
}
if (javax.jws.soap.SOAPBinding.Style.DOCUMENT == jm.getSoapStyle() && javax.jws.soap.SOAPBinding.Use.LITERAL == jm.getSoapUse()) {
return;
}
}
Aggregations