1. miguel riveros
  2. PowerBuilder
  3. Friday, 27 October 2017

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

 

Marco Meoni Accepted Answer Pending Moderation
0
Votes
Undo

 

Hi,
I assume you want to write a PB WS client (not Appeon WS client) and you already have the proxy object in your library (corresponding to the variable proxy_obj).
I also assume you have selected "Use .Net engine" in your WSOAP WS client.

Let PB create the response type for you:
1) In your proxy project, go to Web Service tab e click the button "Services".
2) Here you can select the response structure returned by the Web Service.
3) As you deploy the proxy project, a PB NVO of same type as the response structure will appear in your library.
4) The NVO will contain as many instance variables as the properties of the response structure.

mystr  lstr[]
conn = CREATE SoapConnection
ll_rc = conn.CreateInstance(proxy_obj, 'webservice')
lstr = proxy_obj.wsm_execute(l_logintype,ref ll_responsecode)
// do something with the array

The above steps allow PB to work with any return types and argument types.
Hope it helps, otherwise please post your client code as well as screenshots of the proxy project where the WS definition is visible.
Cheers,
Marco

Comment
Thank for your reply.  I am sending additional info as the prior answer is more or less what I am doing.



 



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





 



 



 



 

  1. miguel riveros
  2. Friday, 27 October 2017
Hi,



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. 

  1. Marco Meoni
  2. Saturday, 28 October 2017
There are no comments made yet.
  1. Friday, 27 October 2017
  2. PowerBuilder
  3. # 1
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.