wsman encoding issue- unicode不受支持 [英] wsman encoding issue- unicode is not supported

查看:73
本文介绍了wsman encoding issue- unicode不受支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们希望在远程机器上执行PowerShell脚本来收集数据。为此,我们使用WSMAN协议。我们正在使用所需的PowerShell脚本发出wsman-soap请求,并使用http将其发送到hyperv机器。执行脚本并使用wsman将
数据发送回给我们,但目前我们发现它不支持unicode字符。因此,由于非英语字符在接收端出现乱码,我们目前无法解决此问题。我们已经检查过Hyperv German
和Hyperv Japanese系统。

We want to execute a PowerShell script on remote machine to collect data. For this we are using WSMAN protocol. We are making a wsman-soap request with required PowerShell script and sending this to hyperv machine using http. There script is executed and data is sent back to us using wsman, but currently we have found that it is not supporting unicode chars. So because of this non-English chars are garbled at receiving end, we are currently not able to resolve this issue. We have checked this for Hyperv German and Hyperv Japanese system.

我认为这是命令行问题。正如您所看到的,我们在soap请求中添加命令shell并且在hyperv机器上执行同样的操作,执行后我们获取base64格式的数据,当我们使用Base64.decode解码接收的数据时,数据
应该以UTF格式提供-8格式,但不幸的是,显示非英语字母乱码数据。

I am thinking this as command line problem. As you can see we are adding command shell in soap request and same is executed on hyperv machine, after execution we are getting data in base64 format, when we are decoding received data using Base64.decode, data should come in UTF-8 format, but unfortunately for non-English char garbled data is shown.

示例肥皂请求:

<?xml version = '1.0 'encoding ='UTF-8'?>               

<?xml version='1.0' encoding='UTF-8'?>               

< s:Envelope xmlns:s ='http://www.w3.org/2003/05/soap-envelope' 的xmlns:A =的" http://schemas.xmlsoap.org/ws/2004/08/addressing' 的xmlns:W =的" http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd'>&NBSP;

<s:Envelope xmlns:s='http://www.w3.org/2003/05/soap-envelope'  xmlns:a='http://schemas.xmlsoap.org/ws/2004/08/addressing'  xmlns:w='http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd'> 

< s:Header>   <一个:至大于HTTP://155.35.128.64:5985 / WSMAN< / A:到大于;&NBSP;&NBSP; < w:ResourceURI s:mustUnderstand ='true'> http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd< / w:ResourceURI>    

<s:Header>   <a:To>http://155.35.128.64:5985/wsman</a:To>   <w:ResourceURI s:mustUnderstand='true'>http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd</w:ResourceURI>    

< a:ReplyTo>      

<a:ReplyTo>      

< a:地址s:mustUnderstand ='true'> http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous< / a:地址>&NBSP;&NBSP;&NBSP;&NBSP;

<a:Address s:mustUnderstand='true'>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>    

< / a:ReplyTo>    

</a:ReplyTo>    

< a:行动s:mustUnderstand ='true'> http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Command< / a:作用>&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;

<a:Action s:mustUnderstand='true'>http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Command</a:Action>        

< w:MaxEnvelopeSize s:mustUnderstand ='true'> 153600< / w:MaxEnvelopeSize>        &NBSP;

<w:MaxEnvelopeSize s:mustUnderstand='true'>153600</w:MaxEnvelopeSize>        

< a:消息ID> uuid:b62d857a-b8ca-4795-b795-d84a3099ce0b< / a:消息ID>       &NBSP;

<a:MessageID>uuid:b62d857a-b8ca-4795-b795-d84a3099ce0b</a:MessageID>       

< w:ContentEncoding> UTF-8< / w:ContentEncoding>         

<w:ContentEncoding> UTF-8 </w:ContentEncoding>         

< w:Locale xml:lang ='en-US's:mustUnderstand ='false'>< / w:Locale>

<w:Locale xml:lang='en-US' s:mustUnderstand='false'></w:Locale>

< w:SelectorSet xmlns:w =" http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">

<w:SelectorSet xmlns:w="http ://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">

< w:Selector Name =" ShellId"> 9FA05544-FC36-454C-8AD1-6E1F41999F98< / w:Selector>

<w:Selector Name="ShellId">9FA05544-FC36-454C-8AD1-6E1F41999F98</w:Selector>

< / w:SelectorSet>

</w:SelectorSet>

< w:OptionSet>

<w:OptionSet>

< w:选项名称='WINRS_CONSOLEMODE_STDIN'> TRUE< / w:选项>

<w:Option Name='WINRS_CONSOLEMODE_STDIN'>TRUE</w:Option>

< / w:OptionSet>

</w:OptionSet>

< w:OperationTimeout> PT60.000S< / w:OperationTimeout>    

<w:OperationTimeout>PT60.000S</w:OperationTimeout>    

< / s:Header>    

</s:Header>    

< s:Body>< CommandLine xmlns ='http://schemas.microsoft.com/wbem/wsman/1/windows/shell'>

<s:Body><CommandLine xmlns='http://schemas.microsoft.com/wbem/wsman/1/windows/shell'>

< Command><![CDATA [echo function main> %TEMP%\ScriptFile-0.3611362671107353.ps1& echo ^ {>> %TEMP%\ScriptFile-0.3611362671107353.ps1& echo ^ $ XenDesktopUser ^ ="" >> %TEMP%\ScriptFile-0.3611362671107353.ps1& echo
gWmi ^ -ComputerName 155.35.128.64 ^ -NameSpace root \virtualization\V2  ^ -query"从Msvm_ComputerSystem中选择*" ^ | Out ^ -File c:\1.txt ^ -encoding'utf8'>> %TEMP%\ScriptFile-0.3611362671107353.ps1& echo ^ $ LoadPercentages ^ = Get ^ -Content
c:\1.txt ^ -encoding'utf8'>> %TEMP%\ScriptFile-0.3611362671107353.ps1& echo ^ $ LoadPercentages>> %TEMP%\ScriptFile-0.3611362671107353.ps1& echo ^}>> %TEMP%\ScriptFile-0.3611362671107353.ps1& echo main>> %TEMP%\ScriptFile-0.3611362671107353.ps1
& Powershell"%TEMP%\ScriptFile-0.3611362671107353.ps1" &安培; Del"%TEMP%\ScriptFile-0.3611362671107353.ps1"]]>

<Command><![CDATA[echo function main > %TEMP%\ScriptFile-0.3611362671107353.ps1&echo ^{ >> %TEMP%\ScriptFile-0.3611362671107353.ps1&echo ^$XenDesktopUser ^= "" >> %TEMP%\ScriptFile-0.3611362671107353.ps1&echo gWmi ^-ComputerName 155.35.128.64 ^-NameSpace root\virtualization\V2  ^-query "Select * from Msvm_ComputerSystem" ^| Out^-File c:\1.txt ^-encoding 'utf8' >> %TEMP%\ScriptFile-0.3611362671107353.ps1&echo ^$LoadPercentages ^= Get^-Content c:\1.txt ^-encoding 'utf8' >> %TEMP%\ScriptFile-0.3611362671107353.ps1&echo ^$LoadPercentages >> %TEMP%\ScriptFile-0.3611362671107353.ps1&echo ^} >> %TEMP%\ScriptFile-0.3611362671107353.ps1&echo main >> %TEMP%\ScriptFile-0.3611362671107353.ps1 & Powershell "%TEMP%\ScriptFile-0.3611362671107353.ps1" & Del "%TEMP%\ScriptFile-0.3611362671107353.ps1"]]>

< / Command>

</Command>

< / CommandLine> < /秒:身体与GT;&NBSP;&NBSP;

</CommandLine></s:Body>  

< / s:信封>

</s:Envelope>

如果您需要我方提供的其他信息,请与我们联系。

Please let me know if you required other information from my side.

推荐答案

您好Abhishek,

Hello Abhishek,

感谢您的提问。协议文档团队的成员将很快回复您。

Thank you for your question. A member of the protocol documentation team will respond to you soon.

致以最诚挚的问候,

Matt Weber | Microsoft开放规范团队

Best regards,
Matt Weber | Microsoft Open Specifications Team


这篇关于wsman encoding issue- unicode不受支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆