Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21839

VB6 vs Web Services

$
0
0
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 :
& ----> &amp;
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

Viewing all articles
Browse latest Browse all 21839

Trending Articles