Using a PowerShell script I invoke a web request and save the response in a variable
$SOAP_RESP=(Invoke-WebRequest $WEB_SRV_URL -Method Post -ContentType "text/xml" -InFile $SOAP_REQ_FILE_PATH).Content
I have email body HTML formatted and I append the earlier obtained SOAP response to it.
$MESSAGE_BODDY="$($HTML_FORMATTED_MESSAGE)<br><br>$($SOAP_RESP)"
Next I want to send an email containing email body from the previous step -BodyAsHtml
Send-MailMessage -From $SMTP_FROM -To $SMTP_TO -Subject $MESSAGE_SUBJECT -Body $MESSAGE_BODDY -BodyAsHtml -Priority high
Obviously, it formats the SOAP response and the email which is delivered is a mess.
Does anyone know how can I deal with this situation? I need SOAP request to be in the email.
[EDIT] The soap response is
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xmm="http://namespace.mynamespace/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<m:service_name xmlns:m="urn:com-s-s-rpc:SYSTEM">
<_INPUT_PARAM>
<UNIT_ID>0dbghfgd</UNIT_ID>
<MSG>test</MSG>
</_INPUT_PARAM>
<_OUTPUT_PARAM>
<RETURN_ERROR_MSG>Invalid Format</RETURN_ERROR_MSG>
</_OUTPUT_PARAM>
</m:service_name>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
What I get in email is only below string (not entire response)
<_INPUT_PARAM>0dbghfgdtest<_OUTPUT_PARAM>Invalid Format