I make a call to a web service
any la_any[]
la_any = proxy_obj.wsm_execute (l_logintype,ref ll_responsecode)
I an forced to use a type ANY because in the response array (Not shown), the service programmer used two reserved fords for the fields names. The web service requires identical names deom the response to be put in the response structure
The original response structure is:
FROM string
TO string
EXANGERATE decimal
DESCRIPTION string.
In order for it to compile, the web service structure is changed to
WS_FROM string ***had to change***
WS_TO string ***had to change it ***
EXANGERATE decimal
DESCRIPTION string.
after changing the structure for the response i cannot use the natural call which should be:
l_ratesinforate = proxy_obj.wsm_execute (l_logintype,ref ll_responsecode) which hangs because L_RATESINFORATE structure has different names for fields.
if I use
any la_any[]
la_any = proxy_obj.wsm_execute (l_logintype,ref ll_responsecode)
in la_any i have 4 records, which I can browse in the debuger and all the data is ok. But I cannot use this data, like in
ls_rates[1].id = la_any[1].id once established the structure ls_rates and instantiating it.
I get the message "INVALID OPERAND TYPE FOR DOT OPERATOR: ANY"
So, the question is how do I extract the data from the array?
thanks
PLEASE BE PATIENT I AM FIGHTING TO GET PICTURES AND ATTACHMENTS
(1) I created a web service proxy in power builder WS_API_RATES (using NEW, Project,Web Service Proxy Wizard) All Ok
Proxy: WS_API_RATES
(2) I created a window with a button that calls the code (see code)
(3) The button invokes the WS call and (Ok if the response goes to ANY; fails if the response goes to structure (RATESINFORATE) created by the wizard.
Please note that the wizard changed two field names (TO was changes do WS_TO and FROM was changed to WS_FROM) see printscreen
(4) FINALLY I'm sending the various screenshots including successful call, failed call and a fiddler print that shows the correct response.
I can send the whole PBL as it is really small, or any format needed for test. thanks
NOTE: CODE AS TEXT, STILL NOT SURE HOW TO ATTACH IMAGES?
In the CLICK envent of a screen button:
SoapConnection conn // Define SoapConnection
ws_api_rates proxy_obj // Declare proxy
long l_rc
int ll_responsecode
string str_endpoint
str_endpoint = "https://www.moresistemas.com:7002/PreProduccion/aWs_Api_Rates.aspx"
//Instantiated connection/definitions/parameters
conn = create SoapConnection
l_rc = Conn.CreateInstance(proxy_obj, "Ws_Api_Rates", str_endpoint)
if l_rc > 0 then
messagebox ('Error','Unable to create service "aWs_Api_Rates"')
return
end if
logintype l_logintype
ratesinforate l_ratesinforate
l_ratesinforate = create ratesinforate
l_logintype = create logintype
l_logintype.branchid = '5071020'
l_logintype.branchip = '192.168.1.23'
l_logintype.branchuser = 'GMAGALLON'
l_logintype.loginpass = '123456'
l_logintype.loginuser = 'WSRPLUS'
try
// call to service
l_ratesinforate = proxy_obj.wsm_execute (l_logintype,ref ll_responsecode) **** FAILS HERE UNLESS THE RESPONSE IS SET TO GO TO A "ANY" TYPE OF VARIABLE
messagebox ("Ok", "Successfull call to Web service")
catch ( SoapException e ) // error handling
messagebox ("Error", "Cannot invoke Web service")
end try
destroy conn
THIS VERSION WORKS oK, BUT NO IDEA HOW TO MANAGE THE ARRAY OF "ANY"
SoapConnection conn // Define SoapConnection
ws_api_rates proxy_obj // Declare proxy
long l_rc
int ll_responsecode
string str_endpoint
str_endpoint = "https://www.moresistemas.com:7002/PreProduccion/aWs_Api_Rates.aspx"
//Instantiated connection/definitions/parameters
conn = create SoapConnection
l_rc = Conn.CreateInstance(proxy_obj, "Ws_Api_Rates", str_endpoint)
if l_rc > 0 then
messagebox ('Error','Unable to create service "aWs_Api_Rates"')
return
end if
logintype l_logintype
ratesinforate l_ratesinforate
l_ratesinforate = create ratesinforate
l_logintype = create logintype
l_logintype.branchid = '5071020'
l_logintype.branchip = '192.168.1.23'
l_logintype.branchuser = 'GMAGALLON'
l_logintype.loginpass = '123456'
l_logintype.loginuser = 'WSRPLUS'
try
// call to service
// l_ratesinforate = proxy_obj.wsm_execute (l_logintype,ref ll_responsecode)
ANY l_any
l_any = proxy_obj.wsm_execute (l_logintype,ref ll_responsecode) *** I get the right answer into an array of ANY, but can'tget it out of the array into regular structure
messagebox ("Ok", "Successfull call to Web service")
catch ( SoapException e ) // error handling
messagebox ("Error", "Cannot invoke Web service")
end try
destroy conn
please show the definition of the return structure AS IT IS DISPLAYED by the PB proxy object. You mention the WS returns multiple records so why you just declare "ratesinforate l_ratesinforate" ? You should have something like "ratesinforate l_ratesinforate[]" (note the square brackets).
In fact, it is not exactly true saying that the declaration above works with ANY return value, as the cast to ratesinforate does not really occur yet when the value is assigned. It is most likely an assignment of a memory pointer but the structure properties are not accessed yet.
Also, please try to get some useful insight in the Catch statement printing the exception with MessageBox("Error", e.GetMessage()).
Cheers,
Marco
P.S.
TO and FROM are probably reserved words, that is why you have to change them, eventually you may wanna see if changing them in the original WS is of any help, but first please fix the problem with the assignment of multiple records as suggested above.