拥有以下脚本:
$query = "<CLAUSE OPER=""equals""><PROPERTY ID=""OrderForm.Status"" TYPE=""STRING"" MULTIVAL=""false"" /><IMMED-VAL TYPE=""STRING""><VALUE>Complete</VALUE></IMMED-VAL></CLAUSE>"
$queryxml = [xml]$query
$so = New-Object Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1bService_OrdersWebService_asmx.SearchOptions
$so.NumberOfRecordsToReturn = 1
$req = $ws.SearchPurchaseOrders($queryxml,$so)
执行时,我收到此错误:
Cannot convert argument "searchClause", with value: "System.Xml.XmlDocument", for "SearchPurchaseOrders" to type "System.Xml.XmlElement": "Cannot convert the "System.Xml.XmlDocument" value
of type "System.Xml.XmlDocument" to type "System.Xml.XmlElement"."
At line:10 char:1
+ $req = $ws.SearchPurchaseOrders($queryxml,$so)
xml没什么问题。我需要名称空间或其他东西吗?
答案 0 :(得分:0)
根据错误判断,SearchPurchaseOrders
期望获得XmlElement
,但是您传递XmlDocument
并且PowerShell无法转换它。您可以使用DocumentElement
属性获取XML文档的根元素:
$req = $ws.SearchPurchaseOrders($queryxml.DocumentElement,$so)