TransformerException of reply message when SOAPConnection.call() fails with no 
connection.
------------------------------------------------------------------------------------------

                 Key: AXIS-2595
                 URL: http://issues.apache.org/jira/browse/AXIS-2595
             Project: Apache Axis
          Issue Type: Bug
    Affects Versions: 1.0-rc2
         Environment: Linux, Fedora 3 equivalent (Momonga 2)
JDK 1.5.0-09 + jpackage 1.6 RPMs including axis-1.4-2jpp
            Reporter: Ichiro Suzuki


When SOAPConnection.call(SOAPMessage, String) fails with no connection 
established,
it returns a message with Fault.  Then, 
Transformer.transform(reply.getSOAPPart().getContent())
fails with,
    javax.xml.transform.TransformerException: Source object passed to ''{0}'' 
has no contents.
.  Strangely, if Transformer.transform(new DOMResult(reply.getSOAPPart())) is 
called beforehand
(this call fails with same exception), subsequent transform() succeeds.

Sample code, soap.java, is Listing 1.
Exception stack trace is Listing 2.
message.writeTo() of the original message is Listing 3.
reply.writeTo() is Listing 4.

==== Listing 1
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;

public class soap {
        public void run() throws Exception {
                MessageFactory mf = MessageFactory.newInstance();
                SOAPMessage m = mf.createMessage();
                SOAPEnvelope e = m.getSOAPPart().getEnvelope();

                SOAPBody b = e.getBody();
                b.addBodyElement(e.createName("Hi", "hi", "urn:Hi"));

                m.writeTo(System.out);
                System.out.println();

                SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
                SOAPConnection c = scf.createConnection();

                SOAPMessage r = c.call(m, "http://localhost:40000";);

                r.writeTo(System.out);
                System.out.println();

                StreamResult result = new StreamResult(System.out);

                Transformer t = 
TransformerFactory.newInstance().newTransformer();
                try {  // this try-catch clause is the work-around
                        t.transform(new DOMSource(r.getSOAPPart()), new 
DOMResult());
                } catch (TransformerException ignored) {}
                t.transform(r.getSOAPPart().getContent(), result);

                System.out.println();
        }

        public static void main(String[] args) throws Exception { 
                try {
                        soap soap = new soap();
                        soap.run();
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
}

==== Listing 2

javax.xml.transform.TransformerException: Source object passed to ''{0}'' has 
no contents.
        at 
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:602)
        at 
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:642)
        at 
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:281)
        at soap.run(soap.java:32)
        at soap.main(soap.java:40)

==== Listing 3

<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><hi:Hi 
xmlns:hi="urn:Hi"/></soapenv:Body></soapenv:Envelope>

==== Listing 4

<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:Server.userException</faultcode><faultstring>java.net.ConnectException:
 Connection refused</faultstring><detail><ns1:stackTrace 
xmlns:ns1="http://xml.apache.org/axis/";>java.net.ConnectException: Connection 
refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
        at java.net.Socket.connect(Socket.java:516)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at 
org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:153)
        at 
org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:120)
        at 
org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
        at 
org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)
        at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)
        at 
org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
        at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
        at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
        at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
        at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
        at org.apache.axis.client.Call.invoke(Call.java:2767)
        at org.apache.axis.client.Call.invoke(Call.java:1870)
        at 
org.apache.axis.soap.SOAPConnectionImpl.call(SOAPConnectionImpl.java:90)
        at soap.run(soap.java:21)
        at soap.main(soap.java:40)
</ns1:stackTrace><ns2:hostname 
xmlns:ns2="http://xml.apache.org/axis/";>chollo</ns2:hostname></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to