简体   繁体   English

带参数的Powershell SOAP请求

[英]Powershell SOAP request with parameter

I need a powershell script to call a soap service, the problem I am currently having is the soap service method has a parameter, I know for sure that I can get the powershell script to work when the method has no parameters but as soon as their is a parameter I receive an error. 我需要一个powershell脚本来调用soap服务,我目前遇到的问题是soap service方法具有一个参数,我可以肯定的是,当方法没有参数时,只要它们没有参数,我就可以使powershell脚本正常工作是一个参数,我收到一个错误。

ie

+ $res = $req.GetResponse <<<< ()
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

Soap request which works (powershell so I have used double quotes where appropriate): 肥皂请求有效(powershell,因此我在适当的地方使用了双引号):

<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
        <soap:Body>
          <CheckStockLevels/>
       </soap:Body>
</soap:Envelope>"

Soap request which doesn't work (powershell so I have used double quotes where appropriate): 肥皂请求不起作用(powershell,因此我在适当的地方使用了双引号):

<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
        <soap:Body>
          <CheckStockLevels>
             <configurationName>123</configurationName>
          </CheckStockLevels>
       </soap:Body>
    </soap:Envelope>"

Does anyone know how I should format the XML for the soap request which doesn't work? 有谁知道我应该如何为不起作用的soap请求格式化XML?

This works? 这样行吗

$soap = [xml]@'
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
 <soap:Body>
  <CheckStockLevels>
    <configurationName>123</configurationName>
  </CheckStockLevels>
 </soap:Body>
</soap:Envelope>" 
'@

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM