powershell 执行 web service方法时 如何创建指定方法对象问题


PowerShell交流中心分类: Questionspowershell 执行 web service方法时 如何创建指定方法对象问题
0
sy790825 asked 6年 ago


代码如下:
$cred = New-Object System.Management.Automation.PsCredential  $user,$pwd
$uri = “http://escnjysp01.xxx.com:8011/sap/bc/srt/wsdl/bndg_E4E8C5BFC72E07F1AD7AD48564570CC8/wsdl11/allinone/standard/document?sap-client=800”
$sap= New-WebServiceProxy -uri $uri -Credential $cred
$sap.CallZSY_LOCK_USER(12345)
webservice 连接已经成功 但执行$sap.CallZSY_LOCK_USER 方法 提示错误
无法将“CallZSY_LOCK_USER”的参数“ZSY_LOCK_USER”(其值为“12345”)转换为类型“Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3andard_document_sap_client_8
00.ZSY_LOCK_USER1”:“无法将“System.Int32”类型的“12345”值转换为“Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3andard_document_sap_client_800.ZSY
_LOCK_USER1”类型。”
 
我的理解需要将参数12345 转换为 Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3andard_document_sap_client_800.ZSY
_LOCK_USER1”类型 对象才行 ,但不知道如何操作,请指点
 
 
 
附 $sap的属性信息,其本身已经是 要求的对象
PS C:\Windows\system32> $sap |gm
 TypeName:Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3andard_document_sap_client_800.ZSY_LOCK_USER
Name                                 MemberType Definition                                                                                                               
—-                                 ———- ———-                                                                                                               
CallZSY_LOCK_USERCompleted           Event      Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3andard_document_sap_client_800.Call…
Disposed                             Event      System.EventHandler Disposed(System.Object, System.EventArgs)                                                            
Abort                                Method     void Abort()                                                                                                             
BeginCallZSY_LOCK_USER               Method     System.IAsyncResult BeginCallZSY_LOCK_USER(Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServi…
CallZSY_LOCK_USER                    Method     Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3andard_document_sap_client_800.ZSY_…
 

×用微信扫描并分享
2 Answers
1
Best Answer
Mooser Lee 管理员 answered 6年 ago

你在控制台中输入[Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3andard_document_sap_client_800.ZSY
_LOCK_USER1] 看这个类型能识别吗? 如果能够,可以用New-Object System.DateTime 2013,2,28 这种写法新建一个对象。
你这个问题我没有具体的环境,不能给定确定答案,只能尝试了。

sy790825 replied 6年 ago

按照您的建议问题已经解决,这个问题困扰我很久了 终于找到解决方案 非常感谢!powershel 功能狠给力 论坛更给力啊 !附测试代码PS C:\Windows\system32> [Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3andard_document_sap_client_800.ZSY_LOCK_USER1]IsPublic IsSerial Name BaseType ——– ——– —- ——– True True ZSY_LOCK_USER1 System.Object PS C:\Windows\system32> $user = New-Object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3andard_document_sap_client_800.ZSY_LOCK_USER1PS C:\Windows\system32> $userIM_EMPNO ——–

0
sy790825 answered 6年 ago

PS C:\Windows\system32> [Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3andard_document_sap_client_800.ZSY_LOCK_USER1]

IsPublic IsSerial Name                                     BaseType                                                                                                      
——– ——– —-                                     ——–                                                                                                      
True     True     ZSY_LOCK_USER1                           System.Object                                                                                                 
PS C:\Windows\system32> $user = New-Object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy3andard_document_sap_client_800.ZSY_LOCK_USER1

PS C:\Windows\system32> $user
IM_EMPNO                                                                                                                                                                 
——–