如何使用PowerShell将SOAP响应对象转换为XML?

发布于 2025-01-28 05:20:41 字数 1618 浏览 0 评论 0 原文

我将数据从我们的Web应用程序发送到Oracle UCM。我面临转换存储在文件中的肥皂响应的挑战。稍后,我从文件中读取该响应,然后转换为XML以获取响应代码。以下是代码:

$response | Out-File  $out_path
$Status=($response.Envelope.Body.uploadFileToUcmResponse.return) 
Write-Host $Status
$soap_object= get-content -path $out_path
[xml] $xml=$soap_object[5..6]
$result=$xml.Envelope.Body.uploadFileToUcmResponse.result."#text"
$result 

我在此行中遇到错误,

**[xml] $xml=$soap_object[5..6]**

无法从对象转换为XML文档。我花了很多时间来解决这个问题。但这是徒劳的。如果您知道答案,请回答我。

以下是我的肥皂反应。

--=_Part_920_1255941941.1652372974539
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: 8bit
Content-ID: <83415eb1-1a64-4eeb-be91-e4ad0b837350>

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing"><env:Header><wsa:Action>http://xmlns.oracle.com/apps/financials/commonModules/shared/financialUtilService/FinancialUtilService/uploadFileToUcmResponse</wsa:Action><wsa:MessageID>urn:uuid:92433bfb-3f44-4a99-8513-8c2a274818fa</wsa:MessageID></env:Header><env:Body><ns0:uploadFileToUcmResponse xmlns:ns0="http://xmlns.oracle.com/apps/financials/commonModules/shared/financialUtilService/types/"><result xmlns="http://xmlns.oracle.com/apps/financials/commonModules/shared/financialUtilService/types/">10211536</result></ns0:uploadFileToUcmResponse></env:Body></env:Envelope>
------=_Part_920_1255941941.1652372974539--

提前致谢。

I am sending data from our web application to Oracle UCM. I am facing challenges to convert SOAP response which is stored in a file. Later I am reading that response from the file and converting to XML to get the response code. Below is the code:

$response | Out-File  $out_path
$Status=($response.Envelope.Body.uploadFileToUcmResponse.return) 
Write-Host $Status
$soap_object= get-content -path $out_path
[xml] $xml=$soap_object[5..6]
$result=$xml.Envelope.Body.uploadFileToUcmResponse.result."#text"
$result 

I am getting error in this line

**[xml] $xml=$soap_object[5..6]**

Unable to convert from object to xml document. I have spend lot time to resolve this issue. but it was in vain. If you know the answer please respond me.

Below is my SOAP response.

--=_Part_920_1255941941.1652372974539
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: 8bit
Content-ID: <83415eb1-1a64-4eeb-be91-e4ad0b837350>

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing"><env:Header><wsa:Action>http://xmlns.oracle.com/apps/financials/commonModules/shared/financialUtilService/FinancialUtilService/uploadFileToUcmResponse</wsa:Action><wsa:MessageID>urn:uuid:92433bfb-3f44-4a99-8513-8c2a274818fa</wsa:MessageID></env:Header><env:Body><ns0:uploadFileToUcmResponse xmlns:ns0="http://xmlns.oracle.com/apps/financials/commonModules/shared/financialUtilService/types/"><result xmlns="http://xmlns.oracle.com/apps/financials/commonModules/shared/financialUtilService/types/">10211536</result></ns0:uploadFileToUcmResponse></env:Body></env:Envelope>
------=_Part_920_1255941941.1652372974539--

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不回头走下去 2025-02-04 05:20:41

更改 [XML] $ xml = $ soap_object [5..6] to [XML] $ xml = $ soap_object [5] ,因为第六行(index 5 )仅包含要解析的XML文本。

但是,除非您需要文件中的标头字段,请考虑使用

$ response.content |外文件$ out_path 为了仅保存响应的 content ,即xml,然后允许您简化 [xml] $ xml = $ xml = $ soap_object

Change [xml] $xml=$soap_object[5..6] to [xml] $xml=$soap_object[5], because the 6th line (index 5) alone contains the XML text you want to parse.

However, unless you need the header fields in your file, consider using
$response.Content | Out-File $out_path in order to only save the response's content, i.e. just the XML, which then allows you to simplify to [xml] $xml=$soap_object

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文