axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Moore, Greg" <Greg_W_Mo...@adp.com>
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 java.io import File

        # xmlfilename contains a complete SOAP Envelope and all the
headers
        xmlFilename = 'aSoapEnvelope.xml'
        xmlData = File(xmlFilename)
        length = xmlData.length()
        url = "http://myserver.somewhere.com/services/Check.asmx"
        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.setRequestEntity(entity)
        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()
       else:
	  # I'd like to check for soap fault here instead of a generic
              # failure.
              print " failure: " + post.getStatusLine().toString()

Hope this helps 

Regards,
Greg,


-----Original Message-----
From: Davanum Srinivas [mailto:davanum@gmail.com] 
Sent: Wednesday, August 01, 2007 9:11 AM
To: axis-user@ws.apache.org
Subject: Re: How to handle soap faults?

Greg,

Can you please post what you have so far?

thanks,
dims



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: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Mime
View raw message