org.apache.axis2.jaxws.handler.SoapMessageContext Maven / Gradle / Ivy
/*
* 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.axis2.jaxws.handler;
import org.apache.axiom.soap.RolePlayer;
import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.core.MessageContext;
import org.apache.axis2.jaxws.i18n.Messages;
import org.apache.axis2.jaxws.message.Block;
import org.apache.axis2.jaxws.message.Message;
import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext;
import org.apache.axis2.jaxws.message.factory.BlockFactory;
import org.apache.axis2.jaxws.message.factory.JAXBBlockFactory;
import org.apache.axis2.jaxws.message.factory.MessageFactory;
import org.apache.axis2.jaxws.registry.FactoryRegistry;
import org.apache.axis2.util.JavaUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.xml.bind.JAXBContext;
import javax.xml.namespace.QName;
import javax.xml.soap.AttachmentPart;
import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
import javax.xml.stream.XMLStreamException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
/**
* The SOAPMessageContext is the context handed to SOAP-based application handlers. It provides
* access to the SOAP message that represents the request or response via SAAJ. It also allows
* access to any properties that have been registered and set on the MessageContext.
*/
public class SoapMessageContext extends BaseMessageContext implements
javax.xml.ws.handler.soap.SOAPMessageContext {
private static final Log log = LogFactory.getLog(SoapMessageContext.class);
// Cache the message object and SOAPMessage after transformation
Message cachedMessage = null;
SOAPMessage cachedSoapMessage = null;
// Cache information about the SOAPMessage so that we can tell if it has changed
SOAPPart cachedSoapPart = null;
SOAPEnvelope cachedSoapEnvelope = null;
List cachedAttachmentParts = new ArrayList();
public SoapMessageContext(MessageContext messageCtx) {
super(messageCtx);
}
public Object[] getHeaders(QName qname, JAXBContext jaxbcontext, boolean allRoles) {
if(log.isDebugEnabled()){
log.debug("Getting all Headers for Qname: "+qname);
}
if(qname == null){
if(log.isDebugEnabled()){
log.debug("Invalid QName, QName cannot be null");
}
throw ExceptionFactory.makeWebServiceException(Messages.getMessage("soapMessageContextErr1"));
}
if(jaxbcontext == null){
if(log.isDebugEnabled()){
log.debug("Invalid JAXBContext, JAXBContext cannot be null");
}
throw ExceptionFactory.makeWebServiceException(Messages.getMessage("soapMessageContextErr2"));
}
// The header information is returned as a list of jaxb objects
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy