axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 22363] New: - Processing SOAPFault when MessageContext is not set.
Date Tue, 12 Aug 2003 22:00:31 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22363>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22363

Processing SOAPFault when MessageContext is not set.

           Summary: Processing SOAPFault when MessageContext is not set.
           Product: Axis
           Version: current (nightly)
          Platform: All
        OS/Version: Linux
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Serialization/Deserialization
        AssignedTo: axis-dev@ws.apache.org
        ReportedBy: steve.johnson@riskmetrics.com


-----------------------------------------------------------
Description
-----------------------------------------------------------
I am using the axis libraries to send/receive SOAP Messages to our backend
platform via JMS/HTTP. Our "web services" are not deployed in Axis, we are only
using the library to serialize/deserialize the actual messages...that seems to
be the crux of the problem.

I've run into an issue when a reponse message contains a SOAPFault. The problem
is that when attempting to deserialize the message a few of the ...Builder
implementations are attempting to access the MessageContext to access the
SOAPConstants.

This occurs in BodyBuilder and SOAPFault builder...I've worked around the issue
by doing the following:

SOAPConstants soapConstants = context.getMessageContext() == null ?			
SOAPConstants.SOAP11_CONSTANTS :						
context.getMessageContext().getSOAPConstants();

then changing all references to the msgContext.getSOAPConstants() to use the
local soapConstants instead.

This works fine, here, however ther is one additional issue...again relating to
the MessageContext being null in our usage.

In apache/axis/encoding/DeserializationContextImpl.java	

the getTypeMapping accesses the messageContext to grab the encoding type, which
of course it cannot do. I worked around this with something like this

    	if( msgContext == null )	{
          TypeMappingRegistryImpl tmr = new TypeMappingRegistryImpl();
          return ( tmr.getOrMakeTypeMapping( Use.LITERAL.getEncoding() ) );

which is fairly useless, in general, however it works for us since all encoding
is LITERAL in our application. There is curElement in this context, however it
appears as if its encoding isn't set.

-----------------------------------------------------------
REPRODUCING
-----------------------------------------------------------
Here's some sample code that will reproduce the problem.

import java.io.*;

import javax.xml.soap.*;

/**
 * @author sjohnson
 */
public class SOAPFaultTest {

	public static final String soapFault = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>" +
	"<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
	 "<soapenv:Body>" +
	  "<soapenv:Fault>" +
	   "<faultcode>soapenv:13001</faultcode>" +
	   "<faultstring>java.lang.Exception: File already exists</faultstring>" +
	  
"<faultactor>urn:RiskMetricsDirect:1.0:object-service-service:CreateObject</faultactor>"
+
	   "<detail/>" +
	  "</soapenv:Fault>" +
	 "</soapenv:Body>" +
	"</soapenv:Envelope>";
	
	/**
	 * Should see 
	 * Caused by: java.lang.NullPointerException
	 * at org.apache.axis.message.BodyBuilder.onStartChild(BodyBuilder.java:196)
	*  at
org.apache.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:949)
	 * @param args
	 */
	public static void main(String[] args) 
	{
		try {
			ByteArrayInputStream bis = new ByteArrayInputStream( soapFault.getBytes() );
			MessageFactory msgFactory = MessageFactory.newInstance();
			SOAPMessage msg = msgFactory.createMessage ( null, bis );
			
			//now attempt to access the fault
			if( msg.getSOAPPart().getEnvelope().getBody().hasFault() )	{
				SOAPFault fault = 
					msg.getSOAPPart().getEnvelope().getBody().getFault();
					System.out.println( "Fault: " + fault.getFaultString() );
			}
		} catch (SOAPException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}

Mime
View raw message