def testSoap(self): # test soap server implementation from gluon.contrib.pysimplesoap.client import SoapClient, SoapFault url = 'http://127.0.0.1:8000/examples/soap_examples/call/soap?WSDL' client = SoapClient(wsdl=url) ret = client.SubIntegers(a=3, b=2) # check that the value returned is ok assert ('SubResult' in ret) assert (ret['SubResult'] == 1) try: ret = client.Division(a=3, b=0) except SoapFault as sf: # verify the exception value is ok # assert(sf.faultstring == "float division by zero") # true only in 2.7 assert (sf.faultcode == "Server.ZeroDivisionError") # store sent and received xml for low level test xml_request = client.xml_request xml_response = client.xml_response # do a low level raw soap request (using s = WebClient('http://127.0.0.1:8000/') try: s.post('examples/soap_examples/call/soap', data=xml_request, method="POST") except urllib2.HTTPError as e: assert (e.msg == 'INTERNAL SERVER ERROR') # check internal server error returned (issue 153) assert (s.status == 500) assert (s.text == xml_response)
def test_soap_sub(): from gluon.contrib.pysimplesoap.client import SoapClient, SoapFault # build the url to the WSDL (web service description) # like "http://localhost:8000/webservices/sample/call/soap?WSDL" url = URL(f="call/soap", vars={"WSDL": ""}, scheme=True) # create a SOAP client client = SoapClient(wsdl=url) # call the SOAP remote method try: ret = client.SubIntegers(a=3, b=2) result = ret['SubResult'] except SoapFault, sf: result = sf
def testSoap(self): # test soap server implementation from gluon.contrib.pysimplesoap.client import SoapClient, SoapFault url = 'http://127.0.0.1:8000/examples/soap_examples/call/soap?WSDL' client = SoapClient(wsdl=url) ret = client.SubIntegers(a=3, b=2) # check that the value returned is ok assert ('SubResult' in ret) assert (ret['SubResult'] == 1) try: ret = client.Division(a=3, b=0) except SoapFault, sf: # verify the exception value is ok # assert(sf.faultstring == "float division by zero") # true only in 2.7 assert (sf.faultcode == "Server.ZeroDivisionError")
def test_soap_sub(): from gluon.contrib.pysimplesoap.client import SoapClient, SoapFault # create a SOAP client url = "http://" + request.wsgi.environ["HTTP_HOST"] + URL( c="sample", f="call", args=[ "soap", ]) + "?WSDL" client = SoapClient(wsdl=url) # call SOAP method response = client.SubIntegers(a=3, b=2) try: result = response['SubResult'] except SoapFault: result = None return dict(xml_request=client.xml_request, xml_response=client.xml_response, result=result)