powershell - 使用 New-WebServiceProxy 命名空间和对象问题的 Powershell 肥皂
问题描述
我正在尝试在powershell中编写一个soap请求服务已经启动我可以用soapui请求它。
在阅读了 this和this之后,我没有设法将我的参数放在 ns.param 对象中。我什至无法创建 ns.param 对象。
如果您需要更多信息来回答,我会尽可能详尽,我会尽快提供。
我想调用这个方法:
search Method ns.resultats search(string login, string password, ns.entite entite, bool entiteSpecified, ns.searchCriteria criteres, bool details, bool c...
在 IDE 中,自动完成显示标准是 ns.param[] 的类型
当我尝试获取 $scParam 变量的成员时,我收到一条错误消息:
gm : Le champ ou la propriété «Value» du type «ns.param» ne diffère que par la casse du champ ou de la propriété «value». Le type doit être compatible avec la spécification CLS (Common
Language Specification).
Au caractère C:\Users\edoua\Documents\test.ps1:13 : 12
$scParam | gm
~~
CategoryInfo : NotSpecified: (:) [Get-Member], ExtendedTypeSystemException
FullyQualifiedErrorId : NotACLSComplaintProperty,Microsoft.PowerShell.Commands.GetMemberCommand
最后,我用 python 和 zeep 库编写了相同的方法,当我将这个字典作为参数传递时,它工作得很好:
{
'login': 'log',
'password': 'pass',
'entite': 'personne',
'criteres': {
'critere': {
'name': 'matricule',
'value': '001002',
'operator': 'eq'
},
'pageNum': 1,
'pageSize': 100
},
'details': True,
'completePath': False
}
最后代码感谢您的帮助:
$url = "http://localhost:8081/search/V1?WSDL"
$WS = New-WebServiceProxy -Uri $url -Namespace ns
$type = $WS.GetType().NameSpace
#Type of object
$typeSc = $type + '.searchCriteria'
$typeScParam = $type + '.param'
# create object
$sc = new-object $typeSc
$scParam = new-object $typeScParam
$scParam | gm
#all crits
$crits = @{}
#one crit
$crit = @{}
$crit["name"] = "matricule"
$crit["operator"] = "eq"
$crit["value"] = "001002"
$crits["critere"] = $crit
# trying to cast crits into sc_param but the first issue is not here
$scParam = $crits
$sc.pageNum = 1
$sc.pageSize = 100
$sc.critere = $scParam
解决方案
推荐阅读
- php - SQL select where conditions 2 if condition 1 不匹配
- javascript - 想要使用 Sheet Js 添加缺失的单元格
- sql - 如何从 Presto 中的 JSON 中提取值?
- java - 如何使用 RichTextFX 更改 JavaFX 中显示的选项卡宽度?
- twilio - 如何在 Twilio WhatsApp 中发送带有文件名的 PDF 文件?
- c# - Unity3D firebase AUTH 不适用于 ANDROID
- java - 如何从外部 .class 文件中获取所有测试方法的名称
- java - 如何从查询中获得结果?(Java、SQL)
- flutter - “IconData”类型不是“Widget”类型的子类型
- operating-system - 访问 ChromeOS 上的系统级功能