T TestMyChess Member Licensed User Longtime User Jan 29, 2013 #1 Hi, This is (almost?) the final piece of the jigsaw that I'd like to get sorted before I get stuck into my app. Chess endgames with 5 and 6 pieces are fully calculated and stored in large databases. The 5-piece ones are online at Tablebase WebService - Lokasoft - Home of ChessPartner. This page has the following VB code to access the database using the MSSOAP toolkit. Code: Dim Client As SoapClient Dim Result As String Set Client = New SoapClient Client.mssoapinit "http://www.lokasoft.nl/tbweb/tbapi.wsdl" Result = SoapClient.ProbePosition("6k1/6p1/8/8/8/8/4P2P/6K1 w - -") What is the B4A equivalent to this code? I've tried looking at httpUtils2 but I'm not getting very far. Thanks in advance. John Harbour Bedford, UK
Hi, This is (almost?) the final piece of the jigsaw that I'd like to get sorted before I get stuck into my app. Chess endgames with 5 and 6 pieces are fully calculated and stored in large databases. The 5-piece ones are online at Tablebase WebService - Lokasoft - Home of ChessPartner. This page has the following VB code to access the database using the MSSOAP toolkit. Code: Dim Client As SoapClient Dim Result As String Set Client = New SoapClient Client.mssoapinit "http://www.lokasoft.nl/tbweb/tbapi.wsdl" Result = SoapClient.ProbePosition("6k1/6p1/8/8/8/8/4P2P/6K1 w - -") What is the B4A equivalent to this code? I've tried looking at httpUtils2 but I'm not getting very far. Thanks in advance. John Harbour Bedford, UK
Erel B4X founder Staff member Licensed User Longtime User Jan 29, 2013 #2 You will need to manually build the XML request and send it with Job.PostString. Upvote 0
T TestMyChess Member Licensed User Longtime User Jan 30, 2013 #3 OK. Can't say I know where to start with "manually build the XML request" but I'll see what I can do. I understand that there is a SOAP client in the Java API. Would it be difficult to create a B4A library that was a wrapper to this? John Harbour Bedford, UK Upvote 0
OK. Can't say I know where to start with "manually build the XML request" but I'll see what I can do. I understand that there is a SOAP client in the Java API. Would it be difficult to create a B4A library that was a wrapper to this? John Harbour Bedford, UK
Erel B4X founder Staff member Licensed User Longtime User Jan 30, 2013 #4 SOAP is based on XML requests and responses. If you can run this VB program you will probably be able to "dump" or browse the request. Upvote 0
SOAP is based on XML requests and responses. If you can run this VB program you will probably be able to "dump" or browse the request.
T TestMyChess Member Licensed User Longtime User Jan 31, 2013 #5 I found Wireshark and so got this XML Code: <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <SOAP-ENV:Envelope xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema" xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAPSDK4:GetBestMoves xmlns:SOAPSDK4="http://lokasoft.org/message/"> <fen> 6k1/8/2Q3K1/8/8/8/8/8 w </fen> </SOAPSDK4:GetBestMoves> </SOAP-ENV:Body> </SOAP-ENV:Envelope> I then hacked the HttpUtils2 example as follows Code: job2.PostString("http://www.lokasoft.nl/tbweb/tbapi.asp", _ "<?xml version=""1.0""...</SOAP-ENV:Envelope>") This gives Code: <h2>500 - Internal server error.</h2> <h3>There is a problem with the resource you are looking for, and it cannot be displayed.</h3> so maybe the XML isn't quite right or I need to set up the HTTP headers (correct jargon?) in some way. I feel I'm close here. I'm feeling a bit guilty wasting Erel's valuable time on my beginner-level hacking, but I'd very much like to get this working. Thanks as always. John Harbour Bedford, UK Upvote 0
I found Wireshark and so got this XML Code: <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <SOAP-ENV:Envelope xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema" xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAPSDK4:GetBestMoves xmlns:SOAPSDK4="http://lokasoft.org/message/"> <fen> 6k1/8/2Q3K1/8/8/8/8/8 w </fen> </SOAPSDK4:GetBestMoves> </SOAP-ENV:Body> </SOAP-ENV:Envelope> I then hacked the HttpUtils2 example as follows Code: job2.PostString("http://www.lokasoft.nl/tbweb/tbapi.asp", _ "<?xml version=""1.0""...</SOAP-ENV:Envelope>") This gives Code: <h2>500 - Internal server error.</h2> <h3>There is a problem with the resource you are looking for, and it cannot be displayed.</h3> so maybe the XML isn't quite right or I need to set up the HTTP headers (correct jargon?) in some way. I feel I'm close here. I'm feeling a bit guilty wasting Erel's valuable time on my beginner-level hacking, but I'd very much like to get this working. Thanks as always. John Harbour Bedford, UK
W wheretheidivides Active Member Licensed User Longtime User Jan 31, 2013 #6 "Does B4A Do SOAP?" I think Netflix does on DVD. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Jan 31, 2013 #7 Save the XML to a file and then load it with File.ReadString(File.DirAssets, "1.xml"). This way you will be sure that there is no typo. Also check the headers with wireshark. You should probably set the ContentType header. Upvote 0
Save the XML to a file and then load it with File.ReadString(File.DirAssets, "1.xml"). This way you will be sure that there is no typo. Also check the headers with wireshark. You should probably set the ContentType header.
T TestMyChess Member Licensed User Longtime User Feb 1, 2013 #8 OK. I've now got Code: job2.PostString("http://www.lokasoft.nl/tbweb/tbapi.asp", _ File.ReadString(File.DirAssets, "GetBestMoves.xml")) and I've changed your code in the HttpJob module to Code: Public Sub PostBytes(Link As String, Data() As Byte) mLink = Link req.InitializePost2(Link, Data) req.SetContentType("text/xml; charset=""UTF-8""") 'JH added CallSubDelayed2(HttpUtils2Service, "SubmitJob", Me) End Sub I wasn't sure where to put this SetContentType() call, but this seemed to be the obvious place. Neither change made any difference - still exactly the same error message. John Harbour Bedford, UK Upvote 0
OK. I've now got Code: job2.PostString("http://www.lokasoft.nl/tbweb/tbapi.asp", _ File.ReadString(File.DirAssets, "GetBestMoves.xml")) and I've changed your code in the HttpJob module to Code: Public Sub PostBytes(Link As String, Data() As Byte) mLink = Link req.InitializePost2(Link, Data) req.SetContentType("text/xml; charset=""UTF-8""") 'JH added CallSubDelayed2(HttpUtils2Service, "SubmitJob", Me) End Sub I wasn't sure where to put this SetContentType() call, but this seemed to be the obvious place. Neither change made any difference - still exactly the same error message. John Harbour Bedford, UK
Erel B4X founder Staff member Licensed User Longtime User Feb 3, 2013 #9 You can add it in the main code: Code: Job.PostString(...) Job.GetRequest.SetContentType(...) You will need to continue looking for the differences between the messages. Upvote 0
You can add it in the main code: Code: Job.PostString(...) Job.GetRequest.SetContentType(...) You will need to continue looking for the differences between the messages.
T TestMyChess Member Licensed User Longtime User Feb 3, 2013 #10 Sorted! Stupidity on my part - I had left some spurious text in the GetBestMoves.xml file. Thanks very much for your help and patience. John Harbour Bedford, UK Upvote 0
Sorted! Stupidity on my part - I had left some spurious text in the GetBestMoves.xml file. Thanks very much for your help and patience. John Harbour Bedford, UK
mariusturnkey Member Licensed User Longtime User Dec 12, 2013 #11 Hi John, I will soon have to embark on a similar mission as what you already seemed to have overcome. Did you take the communication with a SOAP Web Server to completion? In other words were you able to send requests and receive and interpret responses received from the web service in XML packets. Did you have have to build your your own SAX or other XML interpreter on the A4B side? Could you share some of your experiences? Regards Marius Upvote 0
Hi John, I will soon have to embark on a similar mission as what you already seemed to have overcome. Did you take the communication with a SOAP Web Server to completion? In other words were you able to send requests and receive and interpret responses received from the web service in XML packets. Did you have have to build your your own SAX or other XML interpreter on the A4B side? Could you share some of your experiences? Regards Marius
Erel B4X founder Staff member Licensed User Longtime User Dec 13, 2013 #12 SOAP responses are regular XML strings. There are several example of sending and receiving SOAP messages: http://www.b4x.com/android/forum/pages/results/?query=soap&page=1 Upvote 0
SOAP responses are regular XML strings. There are several example of sending and receiving SOAP messages: http://www.b4x.com/android/forum/pages/results/?query=soap&page=1
mariusturnkey Member Licensed User Longtime User Dec 13, 2013 #13 Perfect Errol, Ill give it a bash, I saw lots of messages re SOAP and Web Services. I think what I might do is to try and create a bit of a tutorial once I have managed to get it right, which I can then contribute back to the community. As a database applications developer, the ability to communicate with SOAP Web Service is most probably one of the most important "features" to me. Upvote 0
Perfect Errol, Ill give it a bash, I saw lots of messages re SOAP and Web Services. I think what I might do is to try and create a bit of a tutorial once I have managed to get it right, which I can then contribute back to the community. As a database applications developer, the ability to communicate with SOAP Web Service is most probably one of the most important "features" to me.
T TestMyChess Member Licensed User Longtime User Dec 16, 2013 #14 mariusturnkey said: Hi John, I will soon have to embark on a similar mission as what you already seemed to have overcome. Did you take the communication with a SOAP Web Server to completion? In other words were you able to send requests and receive and interpret responses received from the web service in XML packets. Did you have have to build your your own SAX or other XML interpreter on the A4B side? Could you share some of your experiences? Regards Marius Click to expand... I build this XML string Code: <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <SOAP-ENV:Envelope xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema" xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAPSDK4:GetBestMoves xmlns:SOAPSDK4="http://lokasoft.org/message/"> <fen>4k3/8/8/8/8/8/4P3/4K3 w</fen> </SOAPSDK4:GetBestMoves> </SOAP-ENV:Body> </SOAP-ENV:Envelope> where the only variable is the "4k3/8/8/8/8/8/4P3/4K3 w" which represents a chess position in FEN notation. Then Code: Dim job As HttpJob Dim XML As String = "<?xml ... :Envelope>" job.Initialize("Job", Me) job.PostString("http://www.lokasoft.nl/tbweb/tbapi.asp", XML) job.GetRequest.SetContentType("text/xml; charset=""UTF-8""") Then Code: Sub JobDone (Job As HttpJob) If Job.Success = True Then strResult = Job.GetString strResult contains the list of moves from the passed position. I ignore the fact that these are wrapped up as XML and simply parse out the information I want using a regular expression. Not really what you could call "writing my own XML interpreter", so I can't help you with that bit. Hope this helps. John Upvote 0
mariusturnkey said: Hi John, I will soon have to embark on a similar mission as what you already seemed to have overcome. Did you take the communication with a SOAP Web Server to completion? In other words were you able to send requests and receive and interpret responses received from the web service in XML packets. Did you have have to build your your own SAX or other XML interpreter on the A4B side? Could you share some of your experiences? Regards Marius Click to expand... I build this XML string Code: <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <SOAP-ENV:Envelope xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema" xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAPSDK4:GetBestMoves xmlns:SOAPSDK4="http://lokasoft.org/message/"> <fen>4k3/8/8/8/8/8/4P3/4K3 w</fen> </SOAPSDK4:GetBestMoves> </SOAP-ENV:Body> </SOAP-ENV:Envelope> where the only variable is the "4k3/8/8/8/8/8/4P3/4K3 w" which represents a chess position in FEN notation. Then Code: Dim job As HttpJob Dim XML As String = "<?xml ... :Envelope>" job.Initialize("Job", Me) job.PostString("http://www.lokasoft.nl/tbweb/tbapi.asp", XML) job.GetRequest.SetContentType("text/xml; charset=""UTF-8""") Then Code: Sub JobDone (Job As HttpJob) If Job.Success = True Then strResult = Job.GetString strResult contains the list of moves from the passed position. I ignore the fact that these are wrapped up as XML and simply parse out the information I want using a regular expression. Not really what you could call "writing my own XML interpreter", so I can't help you with that bit. Hope this helps. John
mariusturnkey Member Licensed User Longtime User Dec 16, 2013 #15 Thanks replying John. Once I have implemented I will most definitely post something back to this Forum for the benefit of other members. Regards Marius Upvote 0
Thanks replying John. Once I have implemented I will most definitely post something back to this Forum for the benefit of other members. Regards Marius
mariusturnkey Member Licensed User Longtime User Sep 23, 2014 #16 Hi Rick, Not yet, I got sidetracked with other projects. Regards Marius Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Sep 23, 2014 #17 There are several "soap examples" in the forum. See this one: http://www.b4x.com/android/forum/threads/27080/#content Upvote 0
There are several "soap examples" in the forum. See this one: http://www.b4x.com/android/forum/threads/27080/#content