I have a problem with my application using MSXML2.XMLHTTP40 for comunicate with a Web Service.
I have a string with xml format inside and when there are special characters like &, <, > ...... the web service crash with error of unmarshaling...
This is my simple code :
Dim oXMLHTTP As New MSXML2.XMLHTTP40
Dim SOAPxml As String
SOAPxml = "<?xml version=""1.0"" encoding=""UTF-8""?>"
SOAPxml = SOAPxml & "<soapenv:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema- instance"" xmlns:xsd=""http://www.w3.org
2001/XMLSchema"""
SOAPxml = SOAPxml & " xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:ser=""http://myservice.it/"" > "
SOAPxml = SOAPxml & " <soapenv:Header/> "
SOAPxml = SOAPxml & " <soapenv:Body> "
SOAPxml = SOAPxml & " <ser:methodname> "
SOAPxml = SOAPxml & " <soapenv:Body> "
SOAPxml = SOAPxml & " <arg0>12345</arg0> "
SOAPxml = SOAPxml & " <arg0>R&D</arg0> "
SOAPxml = SOAPxml & " <arg0>DESCRIPTION</arg0> "
SOAPxml = SOAPxml & " </ser:methodname> "
SOAPxml = SOAPxml & " </soapenv:Body> "
SOAPxml = SOAPxml & "</soapenv:Envelope> "
oXMLHTTP.open "POST", Url, False
oXMLHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
oXMLHTTP.setRequestHeader "Connection", "keep-alive"
oXMLHTTP.send SOAPxml
After a lot of web search the solution suggested is to create a parsing function in order to change the special character with the right encode :
& ----> &
I try it and its works.
But, isn't there any other vb object that can do the same thing in a better way?
Thanks
Olivier
I have a string with xml format inside and when there are special characters like &, <, > ...... the web service crash with error of unmarshaling...
This is my simple code :
Dim oXMLHTTP As New MSXML2.XMLHTTP40
Dim SOAPxml As String
SOAPxml = "<?xml version=""1.0"" encoding=""UTF-8""?>"
SOAPxml = SOAPxml & "<soapenv:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema- instance"" xmlns:xsd=""http://www.w3.org
2001/XMLSchema"""
SOAPxml = SOAPxml & " xmlns:soapenv=""http://schemas.xmlsoap.org/soap/envelope/"" xmlns:ser=""http://myservice.it/"" > "
SOAPxml = SOAPxml & " <soapenv:Header/> "
SOAPxml = SOAPxml & " <soapenv:Body> "
SOAPxml = SOAPxml & " <ser:methodname> "
SOAPxml = SOAPxml & " <soapenv:Body> "
SOAPxml = SOAPxml & " <arg0>12345</arg0> "
SOAPxml = SOAPxml & " <arg0>R&D</arg0> "
SOAPxml = SOAPxml & " <arg0>DESCRIPTION</arg0> "
SOAPxml = SOAPxml & " </ser:methodname> "
SOAPxml = SOAPxml & " </soapenv:Body> "
SOAPxml = SOAPxml & "</soapenv:Envelope> "
oXMLHTTP.open "POST", Url, False
oXMLHTTP.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
oXMLHTTP.setRequestHeader "Connection", "keep-alive"
oXMLHTTP.send SOAPxml
After a lot of web search the solution suggested is to create a parsing function in order to change the special character with the right encode :
& ----> &
I try it and its works.
But, isn't there any other vb object that can do the same thing in a better way?
Thanks
Olivier