带参数的Powershell SOAP请求 [英] Powershell SOAP request with parameter
问题描述
我需要一个powershell脚本来调用soap服务,我当前遇到的问题是soap service方法具有一个参数,我确定可以确定当方法没有参数但可以使powershell脚本正常工作时,只要它们是参数,我就会收到错误消息.
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.
即
+ $res = $req.GetResponse <<<< ()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
有效的肥皂请求(powershell,因此我在适当的地方使用了双引号):
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>"
无法使用的肥皂请求(powershell,因此我在适当的地方使用了双引号):
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>"
有人知道我应该如何为不起作用的soap请求格式化XML吗?
Does anyone know how I should format the XML for the soap request which doesn't work?
推荐答案
这有效吗?
$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>"
'@
这篇关于带参数的Powershell SOAP请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!