ws-wss4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fang Jian <jxf6...@yahoo.com>
Subject Re: Unable to create envelope from given source
Date Mon, 14 Nov 2005 21:34:11 GMT
Hi dims,

I use WSS4JHandler, the following code in the method 

 public boolean doReceiver(MessageContext mc,
RequestData reqData) throws WSSecurityException 

caused the problem
        /*
        * After setting the new current message,
probably modified because
        * of decryption, we need to locate the
security header. That is,
        * we force Axis (with getSOAPEnvelope()) to
parse the string, build
        * the new header. Then we examine, look up the
security header
        * and set the header as processed.
        *
        * Please note: find all header elements that
contain the same
        * actor that was given to
processSecurityHeader(). Then
        * check if there is a security header with
this actor.
        */

        SOAPHeader sHeader = null;
        try {
            sHeader =
message.getSOAPPart().getEnvelope().getHeader();
        } catch (Exception ex) {
            throw new
WebServiceException("WSS4JHandler: cannot get SOAP
header after security processing", ex);
        }

More specifically, the line 

sHeader =
message.getSOAPPart().getEnvelope().getHeader();

throwed the exception.

I traced the getEnvelope() class, 

            public SOAPEnvelope getEnvelope()
                throws SOAPException
            {


        if(sourceWasSet)
            sourceWasSet = false;

        lookForEnvelope();
        if(envelope != null)
                {           
                  if(source != null)
                    {
                       
document.removeChild(envelope);
                        envelope =
createEnvelopeFromSource();
                    }
                } else  if(source != null)
                {            
                       envelope =
createEnvelopeFromSource();
                } else
......

            protected Envelope
createEnvelopeFromSource()
                throws SOAPException
            {

/*  48*/        String xmlDecl = lookForXmlDecl();
/*  49*/        javax.xml.transform.Source tmp =
source;
/*  50*/        source = null;
/*  51*/        EnvelopeImpl envelope =
(EnvelopeImpl)EnvelopeFactory.createEnvelope(tmp,
this);


/*  54*/       
if(!envelope.getNamespaceURI().equals("http:
                {/*  55*/           
log.severe("SAAJ0304.ver1_1.msg.invalid.SOAP1.1");
/*  56*/            throw new
SOAPException("InputStream does not represent a valid
SOAP 1.1 Message");
                }

/*  59*/        if(!omitXmlDecl)
                {/*  60*/           
envelope.setOmitXmlDecl("no");
/*  61*/            envelope.setXmlDecl(xmlDecl);
                }
/*  63*/        return envelope;
            }

public class EnvelopeFactory
{
            public EnvelopeFactory()
            {
            }
            public static Envelope
createEnvelope(Source src, SOAPPartImpl soapPart)
                throws SOAPException
            {
                javax.xml.parsers.SAXParser saxParser;

/*  48*/        saxParser = null;
/*  49*/        if(src instanceof StreamSource)
                {/*  50*/            if(src instanceof
JAXMStreamSource)

/*  52*/                try
                        {
/* <-MISALIGNED-> */ /*  52*/                   
((JAXMStreamSource)src).reset();
                        }
/* <-MISALIGNED-> */ /*  53*/               
catch(IOException ioe)
                        {
/* <-MISALIGNED-> */ /*  54*/                   
log.severe("SAAJ0515.source.reset.exception");
/* <-MISALIGNED-> */ /*  55*/                    throw
new SOAPExceptionImpl(ioe);
                        }
/* <-MISALIGNED-> */ /*  59*/            try
                    {
/* <-MISALIGNED-> */ /*  59*/                saxParser
= parserPool.get();
                    }
/* <-MISALIGNED-> */ /*  60*/           
catch(Exception e)
                    {
/* <-MISALIGNED-> */ /*  61*/               
log.severe("SAAJ0601.util.newSAXParser.exception");
/* <-MISALIGNED-> */ /*  62*/                throw new
SOAPExceptionImpl("Couldn't get a SAX parser while
constructing a envelope", e);
                    }
/* <-MISALIGNED-> */ /*  66*/           
org.xml.sax.InputSource is =
SAXSource.sourceToInputSource(src);
                    org.xml.sax.XMLReader
rejectFilter;
/* <-MISALIGNED-> */ /*  69*/            try
                    {
/* <-MISALIGNED-> */ /*  69*/               
rejectFilter = new RejectDoctypeSaxFilter(saxParser);
                    }
/* <-MISALIGNED-> */ /*  70*/           
catch(Exception ex)
                    {
/* <-MISALIGNED-> */ /*  71*/               
log.severe("SAAJ0510.soap.cannot.create.envelope");
/* <-MISALIGNED-> */ /*  72*/                throw new
SOAPExceptionImpl("Unable to create envelope from
given source: ", ex);
                    }
/* <-MISALIGNED-> */ /*  76*/            src = new
SAXSource(rejectFilter, is);
                }
                Envelope env;
/* <-MISALIGNED-> */ /*  80*/        Transformer
transformer =
EfficientStreamingTransformer.newTransformer();
/* <-MISALIGNED-> */ /*  82*/        DOMResult result
= new DOMResult(soapPart);
/* <-MISALIGNED-> */ /*  83*/       
transformer.transform(src, result);
/* <-MISALIGNED-> */ /*  85*/        env =
(Envelope)soapPart.getEnvelope();
/* <-MISALIGNED-> */ /*  86*/        if(saxParser !=
null)
/* <-MISALIGNED-> */ /*  87*/           
parserPool.put(saxParser);/*  89*/        return env;
                Exception ex;/*  90*/        ex;
/*  91*/        if(ex instanceof
SOAPVersionMismatchException)
                {/*  92*/            throw
(SOAPVersionMismatchException)ex;
                } else
                {/*  94*/           
log.severe("SAAJ0511.soap.cannot.create.envelope");
/*  95*/            throw new
SOAPExceptionImpl("Unable to create envelope from
given source: ", ex);
                }
            }
            protected static Logger log =
Logger.getLogger("javax.xml.messaging.saaj.soap",
"com.sun.xml.messaging.saaj.soap.LocalStrings");
            private static ParserPool parserPool = new
ParserPool(5);
}

--- Davanum Srinivas <davanum@gmail.com> wrote:

> .JAX-WS EA is not an environment that we are
> familiar with.. Could you
> please localize the code inside wss4j that is
> causing the problem?
> 
> thanks,
> dims



	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org


Mime
View raw message