SOAP Web Services equivalent kSoap2 of java

gkumar

Active Member
Licensed User
Longtime User
One of the main requirement for our project is to communicate with the SOAP web service methods. Previously with the java and kSoap2 protocol, I am able to parse the response messages.
We have some complex response messages to parse with. I did not find any other sample than the currency converter sample.

We have some method which needs to be called with 2 parameters and needs to parse the response which is having several Xml parent and child elements. Do we have any sample application which parses the response to elements/array etc.?
I tried to retrieve one of the method output, it just returns the html without required value in response text.

Any example can I get in this regard.
Format of the webservice response is like this. Version tag will have the result.

<?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>
<CurrentVersionResponse xmlns="http://**********/">
<CurrentVersionResult>
<Version>string</Version>
</CurrentVersionResult>
</CurrentVersionResponse>
</soap:Body>
</soap:Envelope>
 

gkumar

Active Member
Licensed User
Longtime User
Response is not having value

It just shows the 'Version' tag without any value like below.

** Activity (main) Resume **

ResponseSuccess
<CurrentVersionResult>
<Version><font class=value>string</font></Version>

</CurrentVersionResult>

</CurrentVersionResponse>

</soap:Body>

</soap:Envelope></pre>

</span>

<span>
 
Upvote 0

gkumar

Active Member
Licensed User
Longtime User
How to use Sax parser

Finally I could able to get the response with values. The thing is I have to pass whole xml format of the request as it is. it works for SOAP 1.2.
But the I am not able to get the parsing technique.

I am getting the response like,

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><ValidateLoginResponse xmlns="http://**********/"><ValidateLoginResult><ErrorName /><ErrorMessage /><Token>3f918</Token></ValidateLoginResult></ValidateLoginResponse></soap:Body></soap:Envelope>


Here How I can read "Token" parameter value i.e. 3f918.
I tried like creating xml parser object in global as
Dim XmlParse As SaxParser
and used in response event as
XmlParse.Parse(Response.GetInputStream(), "Parser")
But the XmlParse.Parents.Size returns 0 value.
 
Last edited:
Upvote 0

gkumar

Active Member
Licensed User
Longtime User
Parser code

Now i am able to read one element using Sax parser. I was not using the Parser_StartElement and _EndElement.

One thing I wanted to ask is, like below code only do we need to post the http request as same format XML tag format as we see in Webservices?

Dim XML As String
XML = ""
XML = XML & "<?xml version='1.0' encoding='utf-8'?>"
XML = XML & "<soap12:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap12='http://www.w3.org/2003/05/soap-envelope'>"
XML = XML & "<soap12:Body>"
XML = XML & "<ValidateLogin xmlns='http://********/'>"
XML = XML & "<Username>***</Username>"
XML = XML & "<Password>*****</Password>"
XML = XML & "</ValidateLogin>"
XML = XML & "</soap12:Body>"
XML = XML & "</soap12:Envelope>"
XML = XML.Replace("'", Chr(34))

Dim request As HttpRequest
request.InitializePost2(URL, XML.GetBytes("UTF8"))
 
Last edited:
Upvote 0

kanaida

Active Member
Licensed User
Longtime User
I posted some code around here before that let's you do this easier without having to parse the soap part, just the xml. It also made requests more simple because it used get urls with parameters like asp.net pages instead of put with complex xml. The only requirement was adding a line to Web.config to allow get requests. I was able to ask a web service in one line of code or so then just used xml sax to create a list of objects defined as a b4a type. Then i set them into the tag property in many ui objects for convenience during events etc... By casting the sender object to its original type, reading the tag property cast back to my own type. I'll see if i can post the code later.

Sent from my LG-MS840 using Tapatalk
 
Upvote 0

hdtvirl

Active Member
Licensed User
Longtime User
Kaniada, if you could post an example of your code for both sides ( server/android ) that would be really appreciated.

Regards

BOB
 
Upvote 0
Top