def test_soap11_fault_handling(self): stub = soap.Stub(location="empty") stub.SERVICE = soap.Service( name=None, targetNamespace=None, location="mock_location", schema=None, version=soap.SOAPVersion.SOAP11, methods=[]) try: stub._handle_response(None, None, SOAP11_ERROR_MESSAGE) except soap.SOAPError,e: self.assertEqual(e.faultcode, "Result") self.assertEqual(e.faultstring, None) self.assertEqual(e.faultactor, "Resultset empty2.")
def test_soap12_fault_handling(self): stub = soap.Stub(location="empty") stub.SERVICE = soap.Service( name=None, targetNamespace=None, location="mock_location", schema=None, version=soap.SOAPVersion.SOAP12, methods=[]) try: stub._handle_response(None, None, SOAP12_ERROR_ROLE) except soap.SOAPError,e: self.assertEqual(e.faultcode,"env:Sender") self.assertEqual(e.faultstring, "\nMessage does not have necessary info\n") self.assertEqual(e.faultactor, "http://gizmos.com/order")
def _echo_service(handler=None, input_header=None, output_header=None): if handler is None: handler, handler_state = _echo_handler() EchoSchema = xsd.Schema( 'http://soap.example/echo/types', elementFormDefault=xsd.ElementFormDefault.UNQUALIFIED, simpleTypes=(InputVersion, OutputVersion), complexTypes=(EchoType, InputHeader, OutputHeader), elements={ 'echoRequest': xsd.Element(EchoType), 'echoResponse': xsd.Element(EchoType), 'InputVersion': xsd.Element(InputVersion), 'OutputVersion': xsd.Element(OutputVersion), }, ) echo_method = xsd.Method( function=handler, soapAction='echo', input='echoRequest', inputPartName='input_', input_header=input_header, output='echoResponse', output_header=output_header, outputPartName='result', operationName='echoOperation', ) return soap.Service( name='TestService', targetNamespace='http://soap.example/echo', location='http://soap.example/ws', schema=EchoSchema, version=soap.SOAPVersion.SOAP11, methods={ 'echo': echo_method, }, )
doSHMR_method = xsd.Method( soapAction='shmr#doSHMR', input='doSHMR', inputPartName='parameters', output='doSHMRResponse', outputPartName='parameters', operationName='doSHMR', ) ################################################################################ # SOAP Service IBIVU_Port_SERVICE = soap.Service( name='IBIVU_Port', targetNamespace='shmr', location='%(scheme)s://%(host)s/cgi-bin/shmr_srv.pl', schema=Schema_4c1ac, version=soap.SOAPVersion.SOAP11, methods=[doSHMR_method], ) ################################################################################ # SOAP Service Stub class IBIVU_PortServiceStub(soap.Stub): ''' ''' SERVICE = IBIVU_Port_SERVICE SCHEME = 'http' HOST = 'zeus.few.vu.nl'
sp.prices.append(4.56) sp.prices.append(xsd.NIL) return sp get_stock_price_method = xsd.Method( function=get_stock_price, soapAction="http://code.google.com/p/soapbox/stock/get_stock_price", input="getStockPrice", output="stockPrice", operationName="GetStockPrice") SERVICE11 = soap.Service( name="StockService", targetNamespace="http://code.google.com/p/soapbox/stock.wsdl", # WSDL targetNamespce version=SOAPVersion.SOAP11, # The url were request should be send. location="http://127.0.0.1:8000/stock/soap11", schema=Schema, methods=[get_stock_price_method]) SERVICE12 = soap.Service( # WSDL targetNamespce name="StockService", targetNamespace="http://code.google.com/p/soapbox/stock.wsdl", version=SOAPVersion.SOAP12, # The url where request should be sent. location="http://127.0.0.1:8000/stock/soap12", schema=Schema, methods=[get_stock_price_method])
"ops": xsd.Element("Ops"), "status": xsd.Element("Status") }) PutOps_method = xsd.Method( soapAction="http://polaris.flightdataservices.com/ws/ops/PutOps", input="ops", # Pointer to Schema.elements inputPartName="body", output="status", # Pointer to Schema.elements outputPartName="body", operationName="PutOps") PutOpsPort_SERVICE = soap.Service( name="PutOpsPort", targetNamespace="http://flightdataservices.com/ops.wsdl", location="http://127.0.0.1:8088/mockPutOpsBinding", schema=Schema, version=soap.SOAPVersion.SOAP11, methods=[PutOps_method]) class PutOpsPortServiceStub(soap.Stub): SERVICE = PutOpsPort_SERVICE def PutOps(self, ops): return self.call("PutOps", ops) if __name__ == "__main__": from datetime import datetime stub = PutOpsPortServiceStub()
'http://ESSArch_Instance.ra.se/StorageLogisticsService/storagelogistics', input='storagelogisticsRequest', inputPartName='parameters', output='storagelogisticsResponse', outputPartName='parameters', operationName='storagelogistics', ) ################################################################################ # SOAP Service StorageLogisticsService_Port_SERVICE = soap.Service( name='StorageLogisticsService_Port', targetNamespace='http://ESSArch_Instance.ra.se/StorageLogisticsService', location='%(scheme)s://%(host)s/webservice/StorageLogisticsService', #location='http://ESSArch_Instance.ra.se/webservice/StorageLogisticsService', schema=Schema_55b49, version=soap.SOAPVersion.SOAP11, methods=[storagelogistics_method], ) ################################################################################ # Django Dispatch # Uncomment these lines to turn on dispatching: from django.views.decorators.csrf import csrf_exempt dispatch = csrf_exempt( soap.get_django_dispatch(StorageLogisticsService_Port_SERVICE)) # Put these lines in the urls.py file of your Django project/application: #urlpatterns += patterns('',
input='ops', inputPartName='body', output='status', outputPartName='body', operationName='PutOps', ) ################################################################################ # SOAP Service PutOpsPort_SERVICE = soap.Service( name='PutOpsPort', targetNamespace='http://flightdataservices.com/ops.wsdl', location='%(scheme)s://%(host)s/ws/ops', schema=Schema_c8319, version=soap.SOAPVersion.SOAP11, methods=[PutOps_method], ) ################################################################################ # Django Dispatch # Uncomment these lines to turn on dispatching: #from django.views.decorators.csrf import csrf_exempt #dispatch = csrf_exempt(soap.get_django_dispatch(PutOpsPort_SERVICE)) # Put these lines in the urls.py file of your Django project/application: #urlpatterns += patterns('',
input='CategoriasDisponiblesXTemporada', inputPartName='parameters', output='CategoriasDisponiblesXTemporadaResponse', outputPartName='parameters', operationName='CategoriasDisponiblesXTemporada', style='document', ) ################################################################################ # SOAP Service ServiciosFEBSoap_SERVICE = soap.Service( name='ServiciosFEBSoap', targetNamespace='http://servicios.feb.es/serviciosWeb', location='%(scheme)s://%(host)s/serviciosweb/CompeticionesFEB.asmx', schema=Schema_e4972, version=soap.SOAPVersion.SOAP11, methods=[ TemporadasDisponibles_method, CategoriasDisponiblesXTemporada_method ], ) ################################################################################ # SOAP Service Stub class ServiciosFEBSoapServiceStub(soap.Stub): ''' ''' SERVICE = ServiciosFEBSoap_SERVICE SCHEME = 'http' HOST = 'servicios.feb.es'