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("Micro soft.XMLDO M")
xmlDoc.loadXML(strXML)
dim xmlhttp
set xmlhttp = Server.Createobject("Micro soft.XMLHT TP")
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</fa ultcode>
<faultstring>System.Web.Se rvices.Pro tocols.Soa pException : Server was unable to read request. ---> System.InvalidOperationExc eption: 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.ReadE lementStri ng() at Microsoft.Xml.Serializatio n.Generate dAssembly. XmlSeriali zationRead er1.Read3_ Email(Bool ean isNullable, Boolean checkType) at Microsoft.Xml.Serializatio n.Generate dAssembly. XmlSeriali zationRead er1.Read10 _SendEmail () --- End of inner exception stack trace --- at System.Xml.Serialization.X mlSerializ er.Deseria lize(XmlRe ader xmlReader, String encodingStyle) at System.Xml.Serialization.X mlSerializ er.Deseria lize(XmlRe ader xmlReader) at System.Web.Services.Protoc ols.SoapSe rverProtoc ol.ReadPar ameters() --- End of inner exception stack trace --- at System.Web.Services.Protoc ols.SoapSe rverProtoc ol.ReadPar ameters() at System.Web.Services.Protoc ols.WebSer viceHandle r.Invoke() at System.Web.Services.Protoc ols.WebSer viceHandle r.CoreProc essRequest ()</faults tring>
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
Any ideas?
Thanks.
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("Micro
xmlDoc.loadXML(strXML)
dim xmlhttp
set xmlhttp = Server.Createobject("Micro
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</fa
<faultstring>System.Web.Se
<detail />
</soap:Fault>
</soap:Body>
</soap:Envelope>
Any ideas?
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or, server.urlencode the variables.
ASKER
Is these any way to allow these tags in the SOAP call instead of encoding them on the client side?
Leo
Leo
No. SOAP is used with XML not HTML.