我正在尝试使用Powershells Invoke-Webrequest将肥皂信封发送到受密码保护的Web服务。密码包含“£”字符,这将导致以下错误:
Invoke-WebRequest ...The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:password. The InnerException message was 'There was an error deserializing the object of type System.String. '?inthemiddle' contains invalid UTF8 bytes.'. Please see InnerException for more details.</faultstring></s:Fault></s:Body></s:Envelope>
Run Code Online (Sandbox Code Playgroud)
这是脚本(敏感信息已删除):
[xml]$SOAP = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:MethodName>
<tem:password>passwordtextwit£inthemiddle</tem:password>
</tem:MethodName>
</soapenv:Body>
</soapenv:Envelope>'
$headers = @{"SOAPAction" = "http://tempuri.org/service/MethodName"}
$URI = "https://<MY URI.com>/service.svc"
$out = Invoke-WebRequest $uri -Method post -ContentType 'text/xml' -Body …Run Code Online (Sandbox Code Playgroud)