Skip Navigation LinksHome Page > Forums > SpiraTest Forums > SpiraTest Issues & Questi... > How to access Spira v3.x ...
Hi Nilesh
You would use something like:
from suds.client import Clientfrom suds.xsd.doctor import Import, ImportDoctorfrom suds.wsse import *WDSLFile = http://mySpiraServer.com/SpiraTeam/Services/v4_0/ImportExport.svc?wsdlclient = Client(WDSLFile,doctor=schema_doctor)resp = client.service.Connection_Authenticate("myUsername","myPassword")
Regards
Adam
from suds.client import Client from suds.xsd.doctor import Import, ImportDoctor # Obviously I made this up wsdl_url = 'http://whatever/path/to/wsdl' # Fix missing types with ImportDoctor schema_url = 'http://schemas.microsoft.com/2003/10/Serialization/Arrays' schema_import = Import(schema_url) schema_doctor = ImportDoctor(schema_import) # Pass doctor to Client client = Client(url=wsdl_url, doctor=schema_doctor)
SOAP stands for Simple Object Access Protocol, as the name suggests nothing but a protocol for exchanging structured data between nodes. It uses XML instead of JSON.
In this article, we are going to see how to make SOAP API calls using python. If you want to test out what exactly the payload and response would look like, you can use the below curl command:
Method 1: Using a request
First, we import the requests library, then we define the SOAP URL.
The next and most important step is to format the XML body according to the structure provided in the SOAP URL. To know the format, simply visit the SOAP URL, click the CountryISOCode link, and format the XML accordingly.
Then you simply prepare the headers and make the POST call.
Code:
import requests # SOAP request URL url = "http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso" # structured XML payload = """<?xml version=\"1.0\" encoding=\"utf-8\"?> <soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> <soap:Body> <CountryIntPhoneCode xmlns=\"http://www.oorsprong.org/websamples.countryinfo\"> <sCountryISOCode>IN</sCountryISOCode> </CountryIntPhoneCode> </soap:Body> </soap:Envelope>""" # headers headers = { 'Content-Type': 'text/xml; charset=utf-8' } # POST request response = requests.request("POST", url, headers=headers, data=payload) # prints the response print(response.text) print(response)
The web service domain is defined in an XML schema file (XSD) that Spring-WS will automatically export as a WSDL. Create an XSD file with operations to return a country’s name, population, capital, and currency. For more details about the course check out this link learn selenium includes all topics of Selenium such as Features, Selenium vs QTP, Selenium Tool Suits, Selenium IDE, Selenium IDE Locating Strategies, Selenium WebDriver, WebDriver Features, WebDriver vs RC, WebDriver Installation, etc.
And if you have any questions, please email or call us at +1 (202) 558-6885