3

I'm starting to code in python using pysimplesoap. Testing first against a service available on Internet. I'm stuck trying to parse the result of the Soap query. I coded:

#!/usr/bin/python
from pysimplesoap.client import SoapClient
import pysimplesoap
import logging
logging.basicConfig()

client=SoapClient(wsdl="http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx?wsdl",trace=True)
response = client.VerifyEmail(email="a-valid-gmail-address@gmail.com",LicenseKey="?")
print response

I get the following which means the Soap request was positive:

{'VerifyEmailResult': {'GoodEmail': True, 'LastMailServer': u'gmail-smtp-in.l.google.com', 'ResponseText': u'Mail Server will accept email', 'ResponseCode': 3}}

I now want to extract the value of GoodEmail which is equal to True from "response" and store it in a variable named "result". I tried various things, without success. I must admit I'm very new to Python, and would appreciate help from a knowledgeable person!

Georges Dev
  • 43
  • 1
  • 5

1 Answers1

3

What you get as the response is a Python dict. You can access the GoodEmail value like that:

result = response['VerifyEmailResult']['GoodEmail']

You can read more about Python data types here: http://docs.python.org/2/library/stdtypes.html

Selcuk
  • 57,004
  • 12
  • 102
  • 110
  • 1
    Thanks. I thought I had tried that. Anyway it's exactly what I was looking for. I would have rated your answer but i can't because I don't have 15 points of rating yet. – Georges Dev Mar 13 '14 at 15:56