I've posted some problem I was having around this, so I thought I'd now post the insights and work-arounds that I've come to.
The WS method I was using for test was producing too many items, and I could not properly inspect the full returned string (because Log truncates, and I can't copy a variable in the debugger), so I put up a 'test' web service.
When I use an ASP.NET (proxy) as client, I get a nice clean return:
<Stores><Record><StoreName>Albany Creek</StoreName><Address>Shop 19, Albany Market Place,720 Albany Creek Road,Albany Creek QLD 4035</Address><Phone1>07 xxxx4334</Phone1><Phone2>SS - xxxx 661 140</Phone2><Fax>07 xxxx4313</Fax><Email>[email protected]</Email><StoreSysID>89</StoreSysID><Latitude>-27.345486</Latitude><Longitude>152.966995</Longitude></Record><Record><StoreName>Albury</StoreName><Address>Shop 3, 659 Young Street,Albury,NSW 2640</Address><Phone1>02 xxx2111</Phone1><Phone2></Phone2><Fax>02 xxxx32112</Fax><Email>[email protected]</Email><StoreSysID>117</StoreSysID><Latitude>-36.071899</Latitude><Longitude>146.925766</Longitude></Record><Record><StoreName>Altona</StoreName><Address>114 Millers Road,Altona,VIC 3025</Address><Phone1>03 xxxx522</Phone1><Phone2></Phone2><Fax>03 93144566</Fax><Email>[email protected]</Email><StoreSysID>120</StoreSysID><Latitude>-37.826740</Latitude><Longitude>144.848648</Longitude></Record></Stores>
But B4a has *no* in-built way of handling SOAP, so the return I get from it is this (below):
<?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><StoresListing_TESTResponse xmlns="http://cheesecake.com.au/"><StoresListing_TESTResult><Stores><Record><StoreName>Albany Creek</StoreName><Address>Shop 19, Albany Market Place,720 Albany Creek Road,Albany Creek QLD 4035</Address><Phone1>07 xxxx4334</Phone1><Phone2>SS - xxx1 140</Phone2><Fax>07 xxx313</Fax><Email>[email protected]</Email><StoreSysID>89</StoreSysID><Latitude>-27.345486</Latitude><Longitude>152.966995</Longitude></Record><Record><StoreName>Albury</StoreName><Address>Shop 3, 659 Young Street,Albury,NSW 2640</Address><Phone1>02 xxxx111</Phone1><Phone2></Phone2><Fax>02 xxxx32112</Fax><Email>[email protected]</Email><StoreSysID>117</StoreSysID><Latitude>-36.071899</Latitude><Longitude>146.925766</Longitude></Record><Record><StoreName>Altona</StoreName><Address>114 Millers Road,Altona,VIC 3025</Address><Phone1>03 xxxx22</Phone1><Phone2></Phone2><Fax>03 xxxx566</Fax><Email>[email protected]</Email><StoreSysID>120</StoreSysID><Latitude>-37.826740</Latitude><Longitude>144.848648</Longitude></Record></Stores></StoresListing_TESTResult></StoresListing_TESTResponse></soap:Body></soap:Envelope>
So it occurred to me to just string-slice out the part that I need, replace 'encoded' characters, and present that as XML to the parser.
Works like a charm!
Perhaps this may help someone else.. also happy to hear of any better ways to achieve the outcome
Steve
The WS method I was using for test was producing too many items, and I could not properly inspect the full returned string (because Log truncates, and I can't copy a variable in the debugger), so I put up a 'test' web service.
When I use an ASP.NET (proxy) as client, I get a nice clean return:
<Stores><Record><StoreName>Albany Creek</StoreName><Address>Shop 19, Albany Market Place,720 Albany Creek Road,Albany Creek QLD 4035</Address><Phone1>07 xxxx4334</Phone1><Phone2>SS - xxxx 661 140</Phone2><Fax>07 xxxx4313</Fax><Email>[email protected]</Email><StoreSysID>89</StoreSysID><Latitude>-27.345486</Latitude><Longitude>152.966995</Longitude></Record><Record><StoreName>Albury</StoreName><Address>Shop 3, 659 Young Street,Albury,NSW 2640</Address><Phone1>02 xxx2111</Phone1><Phone2></Phone2><Fax>02 xxxx32112</Fax><Email>[email protected]</Email><StoreSysID>117</StoreSysID><Latitude>-36.071899</Latitude><Longitude>146.925766</Longitude></Record><Record><StoreName>Altona</StoreName><Address>114 Millers Road,Altona,VIC 3025</Address><Phone1>03 xxxx522</Phone1><Phone2></Phone2><Fax>03 93144566</Fax><Email>[email protected]</Email><StoreSysID>120</StoreSysID><Latitude>-37.826740</Latitude><Longitude>144.848648</Longitude></Record></Stores>
But B4a has *no* in-built way of handling SOAP, so the return I get from it is this (below):
<?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><StoresListing_TESTResponse xmlns="http://cheesecake.com.au/"><StoresListing_TESTResult><Stores><Record><StoreName>Albany Creek</StoreName><Address>Shop 19, Albany Market Place,720 Albany Creek Road,Albany Creek QLD 4035</Address><Phone1>07 xxxx4334</Phone1><Phone2>SS - xxx1 140</Phone2><Fax>07 xxx313</Fax><Email>[email protected]</Email><StoreSysID>89</StoreSysID><Latitude>-27.345486</Latitude><Longitude>152.966995</Longitude></Record><Record><StoreName>Albury</StoreName><Address>Shop 3, 659 Young Street,Albury,NSW 2640</Address><Phone1>02 xxxx111</Phone1><Phone2></Phone2><Fax>02 xxxx32112</Fax><Email>[email protected]</Email><StoreSysID>117</StoreSysID><Latitude>-36.071899</Latitude><Longitude>146.925766</Longitude></Record><Record><StoreName>Altona</StoreName><Address>114 Millers Road,Altona,VIC 3025</Address><Phone1>03 xxxx22</Phone1><Phone2></Phone2><Fax>03 xxxx566</Fax><Email>[email protected]</Email><StoreSysID>120</StoreSysID><Latitude>-37.826740</Latitude><Longitude>144.848648</Longitude></Record></Stores></StoresListing_TESTResult></StoresListing_TESTResponse></soap:Body></soap:Envelope>
So it occurred to me to just string-slice out the part that I need, replace 'encoded' characters, and present that as XML to the parser.
B4X:
Sub JobDone (Job As String)
Dim s1 As String, s2 As InputStream, p1 As Int, p2 As Int, xmlname As String
If HttpUtils.IsSuccess(WS_url) Then
s1 = HttpUtils.GetString(WS_url)
s1 = s1.Replace("<", "<").Replace(">", ">")
p1 = s1.IndexOf("<Stores>")
p2 = s1.IndexOf("</Stores>")
s1 = s1.SubString2(p1, p2 +9)
xmlname = "ws_resp.xml"
File.WriteString(File.DirInternalCache, xmlname, s1)
s2 = File.OpenInput(File.DirInternalCache, xmlname)
parser.Parse(s2, "Parser")
End If
End Sub
Works like a charm!
Perhaps this may help someone else.. also happy to hear of any better ways to achieve the outcome
Steve