1. Pepe Cuenca
  2. PowerBuilder
  3. Monday, 15 October 2018 14:09 PM UTC

Good afternoon to everybody, 

 

We have just migrated our application from PB6 to Appeon PB2017 R3. It works fine, but we want to implement some new features. 

One of them is receive data from a webservice, but I just don't know how to do it. 

I've tried doing this:

 

New Datawindow - Grid - From Webservice -  Enter the WSDL - It detects the webservice - Detects the methods - I select the one I need and when I select the returnvalue [RET], it crashes with the message "An invalid resultset parameter type was detected."

 

I'm quite new at this, so I don't know how to do it. 

 

Our webservice WSDL is https://amcspainfresh.qdecalidad.com/webserviceExternal/ws.apps

It's an external WS, so I can't modify anyting. 

 

If anybody could help me, it would be appreciated.

Marco Meoni Accepted Answer Pending Moderation
  1. Monday, 15 October 2018 15:52 PM UTC
  2. PowerBuilder
  3. # 1

Hello Pepe,

you get error because the WS methods do not return a resultset that is viewable in a DW.

They return custom objects like "Proyectos" or "ResultadoTabModule".

You must use WS proxies in order to handle the objects returned by the WS.

File -> New -> Project -> WS Proxy Wizard.

A crash course is here:

https://www.appeon.com/company/events/soap-web-service-crash-course.html

Best,

.m

Comment
  1. Chris Pollach @Appeon
  2. Thursday, 18 October 2018 13:29 PM UTC
Hi Pepe;



If the resulting XML is a simple 2D (rows & columns) set of standard data types - then you can load that straight into a DW object's buffer. If the XML result is of a more complex nature, you'll have to use PB's PBDOM feature to parse the data out via PowerScript.



Regards ... Chris
  1. Helpful
  1. Marco Meoni
  2. Thursday, 18 October 2018 13:49 PM UTC
@ Chris: the result type is not plain 2D, Pepe is fetching custom objects ("Proyectos" or "ResultadoTabModule") via proxies

@ Pepe: the return code from CreateInstance and Getreportscategory will give you some clue



Best,

.m
  1. Helpful
  1. Pepe Cuenca
  2. Friday, 19 October 2018 07:00 AM UTC
Good Morning guys,



The return code of Create instance is 0 (successful), which is stored on rVal variable, and the return code of getreportscategory is also 0 if i make the conversion to long in the messagebox. I don't understand how it could be useful to see the data or insert it in a DW.



Thank you again for your help (and patience)



  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 19 October 2018 13:34 PM UTC
  2. PowerBuilder
  3. # 2

Hi Pepe;

   I just tried using my SOAPUI software to introspect your WSDL and it does not conform ...

Note sure from the above though what the exact issues are.

 

However, the getProject() method works in a WS DataWindow ...

Regards ... Chris

Comment
  1. Pepe Cuenca
  2. Friday, 19 October 2018 14:10 PM UTC
Hi Chris,

To test it in SOAPUI, we use the URL https://amcspainfresh.qdecalidad.com/webserviceExternal/ws.apps?ws=1



The GetProject method returns a list of categories, which is one of the variables needed to execute getreportscategory.



We have different categories, and we select it in the "category" in the parametres of getreportscategory, and it returns us a list of reports. These reports are the ones I want to load in my database.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 19 October 2018 14:21 PM UTC
  2. PowerBuilder
  3. # 3

SOAPUI cannot handle this as a SOAP request ...

 

However, it does seem to get a little further processing it as a REST type of WS ...

In the end though, it still does not work

Comment
There are no comments made yet.
Marco Meoni Accepted Answer Pending Moderation
  1. Saturday, 20 October 2018 05:59 AM UTC
  2. PowerBuilder
  3. # 4

Hello,

your code is wrong. The proxy "getreportscategory" method doesn't return a string.

It returns a "resultadotabmodule", which in turns contains a string and a "TabCategorias" variable.

So, modify as such:

lo_res = proxy_obj.getreportscategory("98e03348f20cf62c735993d0fea96359", "Volcado_AMC_Carcer","2018-10-12",0,50000,"2018-10-18")

messagebox("Respuesta", lo_res.Resultado)

messagebox("Result", lo_res.TabCategoria.IdCategoria)

[... more lo_res.TabCategoria.XXXX...]

and you will get the "OK" return code, a "Volcado_AMC_Carcer" value for category etc etc with all other properties belonging to TabCategoria.

Best,

.m

Comment
  1. Pepe Cuenca
  2. Tuesday, 23 October 2018 06:46 AM UTC
Good Morning Marco,

This way is working ok, I see the response, the IdCategoria and IdNube, which are either string or long.

The problem now is how to see the data(Informes), which is a TabInformesarray type.

I've tried creating a TabInformes variable, and giving it the result of lo_res.tabcategoria.informes

Then, when I see the methods of this variable (la_informes), I can see the "datos" one, which is what I need, but I don't know how to access/see/work with the data...



Here is my code:



SoapConnection conn // Definimos conexión SOAP

webserviceexternalcontrollerservice proxy_obj // Declaramos proxy

long rVal

resultadotabmodule lo_res

Tabinformes la_informes []









conn = create SoapConnection //Creamos instancia de la conexión



// Set trace file to record soap interchange data,

// if string is "", disables the feature



rVal = Conn.CreateInstance(proxy_obj, &

"webserviceexternalcontrollerservice")



try



// Create proxy object

lo_res = proxy_obj.getreportscategory("98e03348f20cf62c735993d0fea96359", "Volcado_AMC_Carcer",dp_1.text,0,50000,dp_1.text)

la_informes = lo_res.tabcategoria.informes





messagebox("Respuesta", lo_res.Resultado)

messagebox("Id Categoria", lo_res.TabCategoria.IdCategoria)

messagebox("Id Nube", lo_res.TabCategoria.IdNube)







catch ( SoapException e )

messagebox ("Error", "WS no accesible")



end try



destroy conn





Thank you again Marco and Chris,



Pepe.

  1. Helpful
  1. Marco Meoni
  2. Tuesday, 23 October 2018 06:55 AM UTC
Ciao Pepe,

I hope you understood now the principle behind PB proxies.

You can access *any* structured data types provided by SOAP/XML WS.

Whenever you need to handle non-primitive data types, the corresponding PB NVOs will be created in you library by the proxy project.

Deploy the proxy project and all is needed for the Web Service client gets into your PBL.

If the WS accepts/returns *nested* structured objects, just use dot notation as in my previous example.

Best regards,

.m
  1. Helpful
  1. Pepe Cuenca
  2. Tuesday, 23 October 2018 13:15 PM UTC
Hi Marco, I think it's understood.

The thing is that the "results" of the category are in the very bottom of the result, and I can't (don't know how) access them.

I've created a variable "lt_informe" of the type tabinformes, and I want to save the "usuario" field.

I create a variable ls_usuario of the type string, and code:

ls_usuario = lt_informe.usuario

I messagebox to see the result and compiles ok, but the execution shows a Null Object Reference.

At the beginning I've changed the lo_res variable to

lo_res = proxy_obj.getreportscategory("98e03348f20cf62c735993d0fea96359", "Volcado_AMC_Carcer",dp_1.text,0,50000,dp_1.text).tabcategoria ,

So I've gone a level further in the XML response...





  1. Helpful
There are no comments made yet.
  • Page :
  • 1


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