Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Encoding XML
Message
From
26/04/2011 21:03:40
 
 
To
All
General information
Forum:
ASP.NET
Category:
SOAP
Title:
Encoding XML
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01508467
Message ID:
01508467
Views:
134
I have a SOAP class which I use when sending some data to a Web Service using low level. This works well. The only issue I have is that when a Web Service method parameter is about receiving some XML. For example, if I have a Web Service method that receives tcUsername and tcPassword as parameters, my SOAP class will build the data like this:
                cSOAPMessage = "<?xml version='1.0' encoding='UTF-8'?>" + _
                 "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' " + _
                 "xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" " + _
                 "xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">" + _
                 "<soapenv:Body>" + _
                 "<" + cMethod + " xmlns=""" + cNamespace + """>" + _
                 lcPostData + _
                 "</" + cMethod + ">" + _
                 "</soapenv:Body>" + _
                 "</soapenv:Envelope>"
The variable lcPostData contains everything needed for the method, such it may be like this:
<tcUsername>MyUsername</tcUsername>
<tcPassword>MyPassword</tcPassword>
Then, later on, I had the request to have a method which receives a XML file. So, I am now sending something like this:
<tcUsername>MyUsername</tcUsername>
<tcPassword>MyPassword</tcPassword>
<tcXML>...</tcXML>
But, the XML file that I am passing as a parameter here as to be encoded. So, basically, for all parameter values, I am replacing the less than character like this:
                    lcValue = oApp.StrTran(loValue, "<", "& lt;")
So, this sends the SOAP envelope to the Web Service. The Web Service then receives the call, redirects it to the proper method, and all parameters that I have defined are properly acknowledged.

The issue I am facing is that if the client is using a high level call, I do not have to encode anything. But, in low level, as I am building a SOAP envelope, I have to make sure that the less than character is encoded for each parameter value I am passing. Otherwise, the SOAP will not have a valid XML envelope and will fail.

So far so good but on the other end, when I try to load the tcXML parameter into the XML class, it will not work as this is not a valid XML because the less than character is encoded. Of course, I can decode it in reverse and then load it into the XML class and that will work. But, then, this could create a problem with someone using the Web Service in a high level mode assuming such character would be present as is in the parameter value.

So, basically, is there a better way to encode the SOAP Web Service method parameter to make sure that at the other end, I will really receive a less than character instead of the encoding such as seen in the oApp.StrTran() line?

Or, should I just detect at the Web Service side that, if I receive a low level call, then only in that situation I will decode in reverse.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Next
Reply
Map
View

Click here to load this message in the networking platform