• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 332
  • Last Modified:

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.
0
Leo Eikelman
Asked:
Leo Eikelman
  • 3
1 Solution
 
alorentzCommented:
probably need to Server.HTMLEncode all your variables before adding to XML string.
0
 
alorentzCommented:
or, server.urlencode the variables.
0
 
Leo EikelmanDirector, IT and Business DevelopmentAuthor Commented:
Is these any way to allow these tags in the SOAP call instead of encoding them on the client side?

Leo
0
 
alorentzCommented:
No.  SOAP is used with XML not HTML.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now