Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cxf.jaxws.interceptors;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.StringWriter;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import java.util.logging.Logger;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriter;
import javax.imageio.stream.ImageOutputStream;
import javax.mail.util.ByteArrayDataSource;
import javax.xml.bind.JAXBContext;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import com.sun.xml.bind.v2.runtime.JAXBContextImpl;
import com.sun.xml.bind.v2.util.DataSourceSource;
import org.apache.cxf.attachment.AttachmentImpl;
import org.apache.cxf.binding.soap.SoapMessage;
import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
import org.apache.cxf.binding.soap.model.SoapBodyInfo;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.databinding.DataBinding;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.interceptor.AttachmentOutInterceptor;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.jaxb.JAXBDataBinding;
import org.apache.cxf.message.Attachment;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.Phase;
import org.apache.cxf.service.Service;
import org.apache.cxf.service.model.BindingMessageInfo;
import org.apache.cxf.service.model.BindingOperationInfo;
import org.apache.cxf.service.model.MessagePartInfo;
import org.apache.cxf.staxutils.StaxUtils;
public class SwAOutInterceptor extends AbstractSoapInterceptor {
private static final Logger LOG = LogUtils.getL7dLogger(SwAOutInterceptor.class);
private static final boolean HAS_SWA_REF_METHOD;
static {
Class cls = JAXBContextImpl.class;
Method m = null;
try {
m = cls.getMethod("hasSwaRef", new Class[0]);
} catch (Exception e) {
//ignore
}
HAS_SWA_REF_METHOD = m != null;
}
AttachmentOutInterceptor attachOut = new AttachmentOutInterceptor();
public SwAOutInterceptor() {
super(Phase.PRE_LOGICAL);
addAfter(HolderOutInterceptor.class.getName());
addBefore(WrapperClassOutInterceptor.class.getName());
}
public void handleMessage(SoapMessage message) throws Fault {
Exchange ex = message.getExchange();
BindingOperationInfo bop = ex.get(BindingOperationInfo.class);
if (bop == null) {
return;
}
if (bop.isUnwrapped()) {
bop = bop.getWrappedOperation();
}
boolean client = isRequestor(message);
BindingMessageInfo bmi = client ? bop.getInput() : bop.getOutput();
if (bmi == null) {
return;
}
SoapBodyInfo sbi = bmi.getExtensor(SoapBodyInfo.class);
if (sbi == null || sbi.getAttachments() == null || sbi.getAttachments().size() == 0) {
Service s = ex.get(Service.class);
DataBinding db = s.getDataBinding();
if (db instanceof JAXBDataBinding
&& hasSwaRef((JAXBDataBinding) db)) {
setupAttachmentOutput(message);
}
return;
}
processAttachments(message, sbi);
}
protected void processAttachments(SoapMessage message, SoapBodyInfo sbi) {
Collection atts = setupAttachmentOutput(message);
List