First of all: to all LAMW group members:
Your work is GREAT !!!!I try to use android as a client of my soap server app as I used to on wince target.
It seems on android target this is very, very different.
I coud not achieve jHttpClient making calls to soap server. (Maybe I was completely wrong in a way doing that - if so - please lighten me up)
I tried to do raw POST, but xml part was always mangled. Server replied with an error.
I looked under the hood
and I figured out workaround.
Below is little example code:
jHttpClient1.ClearNameValueData;
jHttpClient1.AddClientHeader('Content-Type','text/xml; charset=utf-8');
jHttpClient1.AddClientHeader('SOAPAction', '"urn:OSWIntf-IOSW#Wersja"');
content:='<?xml version="1.0" encoding="UTF-8"?>'#13#10
+'<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:OSWIntf-IOSW" '
+'xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" '
+'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'
+'<SOAP-ENV:Body><ns1:Wersja/></SOAP-ENV:Body></SOAP-ENV:Envelope>';
jHttpClient1.AddNameValueData('BODY',content);
jHttpClient1.PostNameValueDataAsync('http://192.168.1.3/soap/IOSW');
"Wersja" is function name I try to call at the server side.
Of course in my POST instead of expected raw xml data was: BODY=<?xml version="1.0".... but encoded as: BODY==3c=3fxml version=3d1.0=3d........
When I changed some lines of
getPostDataString function in a file
jHttpClient.java placed in: C:\lamw\lazandroidmodulewizard\java\lamwdesigner
(starting at line # 163)
from:
result.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
result.append("=");
result.append(URLEncoder.encode(entry.getValue(), "UTF-8"));
to:
if (entry.getKey().equals("BODY")==true) {
result.append(entry.getValue());
} else {
result.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
result.append("=");
result.append(URLEncoder.encode(entry.getValue(), "UTF-8"));
}
then "BODY" key became special. If it is first key then its name will not be used and its value will not be url encoded and xml structure will be fine for soap server.
I have two questions here: Is there any better way to consume soap services wiyh LAMW? Is there possibility to (somehow) use WST package?