The I{method} (namespace) object. @ivar client: A client object. @type client: L{Client} @ivar method: A I{wsdl} method. @type I{wsdl} Method.
| 526 | |
| 527 | |
| 528 | class Method: |
| 529 | """ |
| 530 | The I{method} (namespace) object. |
| 531 | @ivar client: A client object. |
| 532 | @type client: L{Client} |
| 533 | @ivar method: A I{wsdl} method. |
| 534 | @type I{wsdl} Method. |
| 535 | """ |
| 536 | |
| 537 | def __init__(self, client, method): |
| 538 | """ |
| 539 | @param client: A client object. |
| 540 | @type client: L{Client} |
| 541 | @param method: A I{raw} method. |
| 542 | @type I{raw} Method. |
| 543 | """ |
| 544 | self.client = client |
| 545 | self.method = method |
| 546 | |
| 547 | def __call__(self, *args, **kwargs): |
| 548 | """ |
| 549 | Invoke the method. |
| 550 | """ |
| 551 | clientclass = self.clientclass(kwargs) |
| 552 | client = clientclass(self.client, self.method) |
| 553 | if not self.faults(): |
| 554 | try: |
| 555 | return client.invoke(args, kwargs) |
| 556 | except WebFault as e: |
| 557 | return (500, e) |
| 558 | else: |
| 559 | return client.invoke(args, kwargs) |
| 560 | |
| 561 | def faults(self): |
| 562 | """ get faults option """ |
| 563 | return self.client.options.faults |
| 564 | |
| 565 | def clientclass(self, kwargs): |
| 566 | """ get soap client class """ |
| 567 | if SimClient.simulation(kwargs): |
| 568 | return SimClient |
| 569 | else: |
| 570 | return SoapClient |
| 571 | |
| 572 | |
| 573 | class SoapClient: |