axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Moore, Greg" <>
Subject RE: How to handle soap faults?
Date Wed, 01 Aug 2007 16:27:04 GMT
Hi dims,

Sure, but I'll warn you its in Jython so its not straight Java but
pretty readable as is. # are single line comments just like the java // 

        #This handles the imports of the java stuff
        from org.apache.commons.httpclient import *
        from org.apache.commons.httpclient.methods import *
        from import File

        # xmlfilename contains a complete SOAP Envelope and all the
        xmlFilename = 'aSoapEnvelope.xml'
        xmlData = File(xmlFilename)
        length = xmlData.length()
        url = ""
        soapAction = "http://GateWay/Services/Check/GetReportXml"
        # setup the http client -- post method and http headers
        post = PostMethod(url)
        entity = FileRequestEntity(xmlData, "text/xml; charset=utf-8")
        post.addRequestHeader("Content-Length", str(length))
        post.addRequestHeader("Content-type", "text/xml; charset=utf-8")
        post.addRequestHeader("User-Agent", "SQA_TestClient0")
        post.setRequestHeader("SOAPAction", soapAction)
        # every thing is set now fire it off.
        # responseText is whatever the server sends back either 
        # a response containing soap fault or a one containing cdata 
        httpClient = HttpClient()
        statusCode = httpClient.executeMethod(post)
       if statusCode == HttpStatus.SC_OK:
                resultText = post.getResponseBodyAsString()
	  # I'd like to check for soap fault here instead of a generic
              # failure.
              print " failure: " + post.getStatusLine().toString()

Hope this helps 


-----Original Message-----
From: Davanum Srinivas [] 
Sent: Wednesday, August 01, 2007 9:11 AM
Subject: Re: How to handle soap faults?


Can you please post what you have so far?


This message and any attachments are intended only for the use of the addressee and may contain
information that is privileged and confidential. If the reader of the message is not the intended
recipient or an authorized representative of the intended recipient, you are hereby notified
that any dissemination of this communication is strictly prohibited. If you have received
this communication in error, please notify us immediately by e-mail and delete the message
and any attachments from your system.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message