Link to home
Start Free TrialLog in
Avatar of Leo Eikelman
Leo Eikelman

asked on

Passing HTML tags in a SOAP call

Hey guys,

I am trying to pass an email body which has some HTML tags (<br><a><b>etc..) in a SOAP call.  The SOAP calls looks like this:

strXML = "<?xml version=""1.0"" encoding=""utf-8""?>" & _
            "<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>" & _
                  "      <SendEmail xmlns=""some uri"">" & _
                  "            <CallingApplication>" & CallingApplication & "</CallingApplication>" & _
                  "            <MESSAGE>" & _
                  "                  <MESSAGE_ADDRESS_TO>" & MESSAGE_ADDRESS_TO & "</MESSAGE_ADDRESS_TO>" & _
                  "                  <MESSAGE_ADDRESS_FROM>" & MESSAGE_ADDRESS_FROM & "</MESSAGE_ADDRESS_FROM>" & _
                  "                  <MESSAGE_ADDRESS_CC>" & MESSAGE_ADDRESS_CC & "</MESSAGE_ADDRESS_CC>" & _
                  "                  <MESSAGE_ADDRESS_BCC>" & MESSAGE_ADDRESS_BCC & "</MESSAGE_ADDRESS_BCC>" & _
                  "                  <MESSAGE_BODY>" & MESSAGE_BODY & "</MESSAGE_BODY>" & _
                  "                  <MESSAGE_SUBJECT>" & MESSAGE_SUBJECT & "</MESSAGE_SUBJECT>" & _
                  "                  <MESSAGE_BODY_IS_HTML>" & MESSAGE_BODY_IS_HTML & "</MESSAGE_BODY_IS_HTML>" & _
                  "            </MESSAGE>" & _
                  "      </SendEmail>" & _
                  "</soap:Body>" & _
            "</soap:Envelope>"
      
      dim xmlDoc, strResponse
      set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
      xmlDoc.loadXML(strXML)
      dim xmlhttp
      set xmlhttp = Server.Createobject("Microsoft.XMLHTTP")
      xmlhttp.open "POST", "http://axios/sendmail/sendmail.asmx", false
      xmlhttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
      xmlhttp.setRequestHeader "SOAPAction", "some method"      
      xmlhttp.send xmlDoc


This fails on .send if my MESSAGE_BODY parameter contains any HTML tags.  If MESSAGE_BODY  does not have any HTML tags then it works fine.

The error message I get is:

<?xml version="1.0" encoding="utf-8" ?>
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <soap:Body>
- <soap:Fault>
  <faultcode>soap:Client</faultcode>
  <faultstring>System.Web.Services.Protocols.SoapException: Server was unable to read request. ---> System.InvalidOperationException: There is an error in XML document (1, 583). ---> System.Xml.XmlException: 'Text' is an invalid node type. Line 1, position 583. at System.Xml.XmlReader.ReadElementString() at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read3_Email(Boolean isNullable, Boolean checkType) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read10_SendEmail() --- End of inner exception stack trace --- at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle) at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader) at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters() --- End of inner exception stack trace --- at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters() at System.Web.Services.Protocols.WebServiceHandler.Invoke() at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()</faultstring>
  <detail />
  </soap:Fault>
  </soap:Body>
  </soap:Envelope>


Any ideas?


Thanks.
ASKER CERTIFIED SOLUTION
Avatar of alorentz
alorentz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
or, server.urlencode the variables.
Avatar of Leo Eikelman
Leo Eikelman

ASKER

Is these any way to allow these tags in the SOAP call instead of encoding them on the client side?

Leo
No.  SOAP is used with XML not HTML.