简体   繁体   中英

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.

ie

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

Soap request which works (powershell so I have used double quotes where appropriate):

<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):

<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?

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>" 
'@

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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