web-services - SSIS Web 服务脚本任务 wsdl 文件
问题描述
我正在开发一个 SSIS 包,我们必须通过脚本任务在 SSIS 中调用或使用 Web 服务。我已经浏览了很多链接,但我无法找到确切的解决方案。
我的要求是我已经有一个 WSDL 文件。我们需要使用该 WSDL 文件,我们需要识别该 WSDL 中的方法,并且需要将该 WSDL 中可用的数据写入数据库表。我们如何读取 WSDL 文件以及如何将数据加载到 DB 表中。
提前致谢
解决方案
这可以使用 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)
推荐阅读
- spring-boot - 实体未映射到具有一个表的继承实体的单个属性错误
- flutter - BLE 中的心率值
- avfoundation - AVAudioEngine:播放 Int16 PCM 样本流
- python - 如何创建多图像输入和单输出张量流数据集
- android - 在构建版本中找不到数据类 Kotlin 的序列化程序
- javascript - 用于 webdriverio 的 css 选择器,用于从表中捕获数据
- slider - 商店用品滑块横幅未完全显示
- c# - 过滤集合匹配字段与内存中的另一个列表
- python - Python Sqlite3 - Null 作为元组中的非第一个元素不起作用
- .net - 如何在 PowerShell 5 中定义和使用自定义属性?