cancel
Showing results for 
Search instead for 
Did you mean: 

Web service gets called twice

Former Member
0 Kudos

Hello,

using CAF I have specified a business object Book and a parent object Page. Futhermore, I have specified an application service which contains an operation for storing a Book and a second operation for storing the corresponding Pages.

In VC I have modeled a dialog which contains a form for entering the meta information on a book and a table for entering the information on the pages of the book.

When I click on a submit button I invoke the web service operation for storing the book which returns me the key of the just created book. This service works as expected.

Secondly, I invoke the web service operation for storing the pages by selecting all rows*) from the table. Besides the rows of the table this operation takes the key of the just created book as input.

The operation is supposed to store each row of the table as a Page and creates the association link between the considered page and the book.

However, debugging my code I learned that this operation unintentionally gets called twice resulting in each Page being created and linked to the Book twice.

Does anyone have a clue what I am doing wrong and how to fix it?

*) When I select "current row" instead the selected row is stored twice as well.

Thanks a lot

Alexander

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Alexander,

Are you using the same "Submit" action for both the Web Services? Is it possible to insert the link of your model design?

Best regards,

Dharmi

Edited by: Dharmi Tanna on Jul 9, 2008 2:20 PM

Former Member
0 Kudos

Hi Dharmi,

> Are you using the same "Submit" action for both the Web Services?

Yes, both transitions use "*submit" as trigger.

> Is it possible to insert the link of your model design?

What do you mean with "link"? Do you mean an url to a screenshot of the model?

Thanks a lot

Alexander

Remark: Before having implemented two separate operations for storing a book and its pages I had implemented a single operation which took a complex structure consisting of the book and its pages as input. However, the VC appeared not to be able to deal with this structure and threw exceptions at runtime.

Former Member
0 Kudos

Hi Alexander,

Yes, I mean the screenshot. That is strange, I have the web service which has 3 input ports and it works very well, have a look at the screenshot, if you like on the following thread.....

Could be the CAF issue... Did you try to test it with WS Navigator, or with Strike Iron?

Best regards,

Dharmi

Former Member
0 Kudos

[Here|http://img232.imageshack.us/img232/2395/xbooksvcmodeltb7.png] is my toy model.

Best regards

Alexander

Former Member
0 Kudos

Hi Alexander,

Looks like you have just one button???

Following things to try:

1. Remove the * form the submit

2. Remove the flow from the "saveBook" output to the input of "SavePagesofbook"

3. Place Data store in your model and right click, define data -> add key to it

3. Add the "Assign" method after submit which you could use to fill the key of data store from your book Form

3. Put the new method "Save" for the table and that would call your "SavePagesofBook" web service.

Hope this is clear.

Regards,

Dharmi

Former Member
0 Kudos

Hi Dharmi,

> Looks like you have just one button???

Basically, this is true, as I only want to save the book and its pages as a whole. Otherwise, I could end up with incomplete books.

> 1. Remove the * form the submit

As the submit-button belongs to the book form the star is needed at the transition that ends at the savepagesofbook service. Otherwise, the event would not be "visible" to this transition and no page would ever get saved.

> 2. Remove the flow from the "saveBook" output to the input of "SavePagesofbook"

This flow is needed as the web service takes the id of the book as input.

> 3. Place Data store in your model and right click, define data -> add key to it

> 3. Add the "Assign" method after submit which you could use to fill the key of data store from your book Form

> 3. Put the new method "Save" for the table and that would call your "SavePagesofBook" web service.

If I get you right you propose to have one button for saving the book and a second for storing the pages, right? That's not what I am aiming at.

Best regards

Alexandcer

Former Member
0 Kudos

Hi Alexander,

Since you would like to do it with one button, which is in book Form, Here:

1. You still need to remove this flow - "Remove the flow from the "saveBook" output to the input of "SavePagesofbook" I know you are having the key which is input to the webservice, this is the reason your web service is runing twice!

2. The id of the book can be assigned to Data Store with "Place Data store in your model and right click, define data -> add Book_id field to it

3. Add the "Assign" method after submit which you could use to fill the Book_id of data store from your ID book Form "

4. Put the "Save" action after the "Submit" and "Assign" and that is your flow to "SavePagesbook" web service. (all datarows selected)

Best regards,

Dharmi

p.s I think since the button is on the Form and not the table it might result in sending only one row of that table... Let me know.

Former Member
0 Kudos

Hi Dharmi,

thank you very much for your patience with me. I am quite new to VC. Unfortunately, I still do not understand your proposal.

> 1. You still need to remove this flow - "Remove the flow from the "saveBook" output to the input of "SavePagesofbook" I know you are having the key which is input to the webservice, this is the reason your web service is runing twice!

I agree that the web service is called twice because of the second flow. But, if I remove the second flow how do I map the bookId which is the output of the savebook operation to the input port of the savepagesofbook operation?

> 2. The id of the book can be assigned to Data Store with "Place Data store in your model and right click, define data -> add Book_id field to it

Ok, I can do that. But this leads me to the third point.

> 3. Add the "Assign" method after submit which you could use to fill the Book_id of data store from your ID book Form "

What is the target of the "Assign" method? I want to assign the value to the input port of the web service operation, don't I? But I can only assign the value to a form or a table.

> p.s I think since the button is on the Form and not the table it might result in sending only one row of that table... Let me know.

This seems to work as intended. All rows rather than a single row are processed.

Thank you very much

Alexander

Former Member
0 Kudos

Hi Alexander,

Usage of *submit works as intended (for all the rows), is something I learned.


But, if I remove the second flow how do I map the bookId which is the output of the savebook operation to the input port of the savepagesofbook operation?

You can take the flow form your output to the data store and store the Bookid in the created field. Something like [this|http://img503.imageshack.us/img503/9337/storesi6.jpg]

Here it is pirce_list and in your case it can be "Book_id".

While giving the input to the second web service you can give the book id as


=store@Book_id

Don't use "Save" just use "*Submit"

Regards,

Dharmi

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Dharmi,

after a while of trial-and-error I found a solution based on your proposals.

The resulting model can be seen [here|http://img529.imageshack.us/img529/9581/solutionfw0.png].

Basically, the solution is that the button invokes two actions (i.e., submit and save).

The submit action triggers the saveBook operation and stores the resulting bookId in a data store.

The save action which is invoked after is used to provide the second operation with the needed parameters taking the bookId from the data store into account.

Best regards

Alexander

Former Member
0 Kudos

Hi Alexander,

Glad to know it worked. Thanks for the points.

Regards,

Dharmi