Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Python tool processing single request

Hemachandra
6 - Meteoroid

Hi 

 

i have to use  Python tool to download data from a SOAP based  XML web service and  i had to process multiple requests and passing those as input rows to python tool only 1 request got processed. I am new to this tool and python using it for the first time. This issue could be that way i am using the data frame.

 

Attached are screenshots:

 

1. input rows (browse tool)

2.output row (browse tool)

 

My Python code  which processes each XML request is :

 

import io
import requests
import pandas as pd
from ayx import Alteryx
from requests import Session

df = Alteryx.read("#1")
xml =df.iloc[0, df.columns.get_loc('xml_request')]

 

df = Alteryx.read("#1")
xml =df.iloc[0, df.columns.get_loc('xml_request')]

 

headers = {'Content-Type': 'text/xml'} # set what your server accepts
response = requests.post('https://yourendpoint.com?WSDL', data=xml, headers=headers, cert=('cert.pem','key.pem'),verify=True)

 

data = io.StringIO(response.text)
df2 =pd.read_csv(data, header=None)

 

Alteryx.write(df2,1)

 

am i supposed to be looping the code and create a data frame as an array before sending it out ?

 

Thank you

Hemachandra

 

 

 

 

2 REPLIES 2
PhilipMannering
16 - Nebula
16 - Nebula

Hi @Hemachandra .

 

I don't suppose you can attach the workflow?

Hemachandra
6 - Meteoroid

Hi Philip,

 

yes, due to sensitivity of data and service details, i am unable to attach the workflow.

 

i understand how Python tool works now, it takes the entire input as a Dataframe and we have to handle the record set within the Python script and 

return a equivalent response arrary.

So i used a "For loop" to traverse and process each request and result was appended into a Dataframe array and return it through Alteryx.write(). 

 

 

Thanks

Hemachandra

 

 

Labels