from SOAPpy import SOAPProxy, SOAPConfig

print "============================== SOAP getActivities() results : "

server_url="http://rod.eionet.eu.int/soaprouter"
server = SOAPProxy( server_url ,
    config=SOAPConfig(debug=1),
    namespace = "urn:WebRODService",
    encoding = None)

resp = server.getActivities()
itemList = resp._getItemAsList("item")


print "Activities count: "
print len(itemList)

c=0
while c < len(itemList):
    act = itemList[c]
    actFields = act._getItemAsList("item")    

    titleList = actFields[2]
    pkList = actFields[3]    
    srcFkList = actFields[1]
    srcTitleList = actFields[0]

    pk = pkList._getItemAsList("value")
    title = titleList._getItemAsList("value")
    fk = srcFkList._getItemAsList("value")
    srcTitle=srcTitleList._getItemAsList("value")

    print "================================"
    print "PK_RA_ID:" + pk[0]
    print "TITLE:" + title[0]
    print "FK_SOURCE_ID:" + fk[0]
    print "SRC_TITLE:" + srcTitle[0]
    
    c=c+1

print "================================"
print "<<< OK >>> "

