SSIS Web服务脚本任务wsdl文件

时间:2018-07-18 14:40:46

标签: web-services ssis wsdl

我正在研究一个SSIS包,我们必须通过脚本任务在SSIS中调用或使用Web服务。我已经遍历了很多链接,但是找不到确切的解决方案。

我的要求是我已经有一个WSDL文件。我们需要使用该WSDL文件,并且需要标识该WSDL中的方法,并且需要将该WSDL中可用的数据写入数据库表中。我们如何读取WSDL文件以及如何将数据加载到DB表中。

预先感谢

1 个答案:

答案 0 :(得分:0)

这可以使用python和名为Zeep的模块来完成,我添加了一种方法,可将来自该API调用的结果插入后端,但是如果按原样运行,则应在WSDL文件中返回该方法调用。在这种情况下,您只需要创建一个接受varchar值的表,称为“ WSDLMethods”。

import operator
import pypyodbc
from zeep import Client

dbUser = ''
dbPass = ''
mydatabase = ''
myserver = ''

methodlist = []
wsdl = 'https://ws.cdyne.com/delayedstockquote/delayedstockquote.asmx?wsdl'
client = Client(wsdl=wsdl)
for service in client.wsdl.services.values():
    print ("service:", service.name)
    for port in service.ports.values():
        operations = sorted(
            port.binding._operations.values(),
            key=operator.attrgetter('name'))
        for operation in operations:
            methodlist.append(operation.name)

#remove duplicates from list
methodlist = list(set(methodlist))

def insertToDB(methodName):
    connection = pypyodbc.connect('Driver={SQL Server};Server='+myserver+';Database=' +str(mydatabase) +';uid='+ str(dbUser)+';pwd=' + str(dbPass)+'')
    cursor = connection.cursor()
    SQLCommand = (" INSERT INTO WSDLMethods VALUES('" + str(methodName) + "')")
    print(SQLCommand)
    cursor.execute(SQLCommand)
    cursor.close()
    connection.commit()
    connection.close()

for method in methodlist:
    #insertToDB(method)
    print(method)