Python uses suds to call WebService

Source: Internet
Author: User
Tags soap client

The old WebService calling methods described in dive into Python need the following packages: pyxml, fpconst, soappy

Basically, the above packages will not be maintained in or later, and most of them will not support python2.5 or later versions. Obviously, if we want to use these packages, it will be quite painful, on stackoverflow, someone asked the "best" Soap client in Python, and someone replied: click here to view details.

I carefully read the reply and finally chose suds.

Url = "http://example.com/test.asmx? WSDL "client = client (URL) # view the remote method print Client # simply call the client. service. hello () # Passing object parameters (method 1) # assume that I have made a class of the C-type, which has two attributes: P1 and P2. M = client. factory. create ('mysql') M. p1 = "my name is" M. p2 = "Walker" result = client. service. classin (m) print result # Pass object parameters (method 2) M = {"p1": "My name is", "p2 ": "Walker"} client = client (URL) Result = client. service. classin (m) print result # returned object result = client. service. classout () print result. p1 # visible returned objects can be directly used # demonstrate suds to package exceptions into a metagroup and send client = client (URL, faults = false) Result = client. service. classin ("fadlskfjsdafjk") print result
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.