Use Web Services

Use Web Services

  
Hello,
I'm new to Outsystems development and I'm using it to my final project in university.
I have a web service that giving it a Costumer Code, it returns the Costumer Details.
I have created a text box and a button in a Web Screen and a local variable for the Costumer Code that I've set to the text box.
In the Action for the button I've put the web service's method in the canvas but can´t figure out what to do next.
I'd like to have a List Records widget in the initial Web Screen showing the results but don't know how to get the results from the web service and put them in the List Records widget.

Best regards,
Nelson André
Hi Nelson,

Don't know if understood your problem quite well, but here goes...

Do you have a screen preparation already? If not, on the rigth side panel, (with something like a directory tree, with all the webscreens, entities,structures, etc..) you just right click the web screen you mentioned, and then, choose "add preparation", or something like that.

Afterwards, while inside the screen preparation, you should add a user action to it, that should correspond to your method....

Then, create a local variable of type record, and with definition of those customer details you want.

You should probably add an entity or a structure with the fields you need....


Oh, and then you should set the destination for the button, the webscreen where your list records is...

Have I undersood your problem and give you any help?

Hope so....

Best regards,

Diogo CS Cordeiro
Thanks for your reply, I will try to explain better.

I have a web service that accepts a string (client code) and returns an array of strings (client details, 28 positions).
I have a Web Screen with an Input field (client code), a button and a List Records widget.
I have created a Structure with 28 attributes = client details, then created 2 local variables: 1 of type string for the client code (set the Variable parameter of the Input field to this local variable) and 1 of type Record List (set the Record Definition to my Structure).
When I double click the Button it creates an Action called "ok", in the Action's flow I dragged my Web Services method to the canvas and set it's input argument to my client code local variable.
In the canvas I have START -> Web Service Method -> Destination (Initial Web Screen where I have the List Records).
Now my question is how can I put the results returned by my Web Service into my local variable of type Record List? It never shows up for selection.

Best regards,
Nelson
Well, since what you want is to list details of a certain "client", you should add a screen preparation...

What's your output from the method? Do you have any?



Do you have a database with client details, which your method alters, is that it?

You should add a query to your screen preparation, with client code as an input, and then just return the details...


Perhaps you could attach your oml, for a more understanding of the problem?
Here it goes my oml file.
My method returns an array of strings with 28 positions with information relative to a certain client.
I have a database with client related information and my web service accesses it to return information only.
hmmmm...If all you want is to get information from a database, you should consider one of two hypothesis:

1- Add a view to that table,

2- Access the table directly


With Integration Studio create an extension which references that view or table.

Then, after uploading the extension to your hub server, you can add it to your project by clicking the "add/remove references" option in Service Studio.

With that, you get a new entity and to access it you just need to do a simple query with argument client Code.

Why would you need that method? Anything you can't do with sql?
As I told you in the begining, I'm doing this for my final project of my university degree with the theme of Software Factories.
The goal is to have a Webservice developed with the Web Service Software Factory from Microsoft and the client side developed with Outsystems.

In a real environment, for example it's like I had some Order Management System and provided some Web Services to clients to be able to put orders or check product listings from their systems. For my project i'm playing both sides.

For the matter , let's say I can't access the database directly and someone just provided me with this webservice.
Hi Nelson,

I took the liberty of making some changes to your OML (in the attached file), which I'll explain here:

- First, as you only want to display one record, I changed your Home screen from a List record to a Show record - the right widget for the job. Also, note that the widget's source record was set to LTData (the LandTransportDataStructure), which was converted from a Record List to a single Record.
- Next, after you invoke the webservice, I perform an assign on the fields of LTData. This is not a regular or typical assign, because it's made using record list indexing (the [i] constructs that indicate what is the record list position you are accessing). This step will effectively assign each Text (from the webservice) to a field in this structure. It's now up to you to fill in the rest of the blanks :)
- Finally, I've changed your Ok action to finish in an End node, which means state will be maintained and your ShowRecord will be updated with the information we have just assigned.

I have no way of testing this so I'm kind of working in the dark here, but maybe it can help you solve your problem. Please get back to the forum if you need any further help.

Just one more question. I know you're kind of "role playing", but couldn't your Order Management System return an aggregated Record instead of a list of strings? :) It's not that far fetched...

Anyway, have fun developing and we'll be here in case you need any more help.
Cheers,
Gonçalo Gaiolas
It's working just like I wanted! Thank you very much!
Beside using the wrong widget to show the records, what I was really missing was that Assign step, I couldn't figure out how to put the values from the Web Service into the Structure.
Now that I know how to do this I can really go further to more complex examples.
Thanks a lot!
Hi André,

Really glad I could help. The assign step was not trivial because your web service is not that common, returning a list of Texts. It would be easier if it could return a structure that you could use on the assign.

Also, don't underestimate the importance of the End node. Without it your page would be completely rendered from scratch and you'd lose the values returned from the Web service. The End node guarantees that your state is kept between server round-trips.

Anyway, have fun developing the rest of your project and don't hesitate to get back to the forums if you need any additional help or tips.
Cheers,
Gonçalo