cancel
Showing results for 
Search instead for 
Did you mean: 

Where to call web service best?

Former Member
0 Kudos

Hi there,

I'm using WDJ in the context of CE 7.2.

I've managed to call web services in WDJ via the adaptive web service model.

But what's not really clear to me:

Should I call the web service in the component/custom controller or should I do it in the view itself?

Is there a best practice for that?

Or does it just depend on the fact, if the data has to be available in more than one view or not?

What I've also experienced:

When you have a WS call in a component/custom controller and you add another model binding, the generated coding is messed up and you have to do some manual work to fix the problem (e.g . correct the init_* method).

Is that a bug in the service controller functionality?

Also, when I delete a model binding again, the coding of the service controller is not deleted, I've to manually delete all the generated methods (init_, execute_).

Is there a way to delete service controller coding automatically?

It seems that service controllers always remain, because when I implement the next model binding, the service controller number is increased (Service Controller *), although I've deleted all the coding in the corresponding .JAVA file.

Thanks in advance!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Its a best practice to have your model execution in Component Controller instead of Views which adhere to MVC.

Thanks,

Nandini

Former Member
0 Kudos

Hi Nandini,

I get your point regarding the MVC concept.

But when I create more than one model binding to a service with the same name (e.g findAll() of a CAF business object), the newly implemented service controller always corrupts the coding and I have to adjust manually.

Is that normal?

Answers (1)

Answers (1)

Former Member
0 Kudos

hi eddie

I think you can use a different dc for service call instead of using custom controller or view .It is much easier and easy to understand as in your main dc you don't have to do much coding just call the method exposed in used dc.

If there are many service calls it is good to use and easier to manage.

Best regards

Suresh

Former Member
0 Kudos

Hi Suresh,

do you have an example how I could do that?

I am new to WDJ, actually I'm an ABAP developer, so you have to excuse my question

But is it normal that sometimes the code is messed up when creating a service controller?

If I would use another DC, would I also create a service controller there, or would I implement everything by myself?

Former Member
0 Kudos

Hi Eddie,

Its always a good practice to use a different DC for creating models and service controllers such DC's should be faceless and only used to consume the services and should act as data supplier to other UI DC.

you can use service controller or you can code both ways are fine. while using service controller you should take care that you supply all the mandatory objects to the request.

Regards

Jeetendra

Former Member
0 Kudos

hi eddie

It is always better to do yourself when you write code yourself it is less prone to mistakes

Make a new dc (for ex model dc) ,import web service (model) in this dc,Create a method in component controller and call web service in this method,

Expose this method and the context nodes,make the component public

In main dc add (model dc ) in dependencies of your main dc.

you can access the context of model dc through used DC's and also call the method where you added code for calling the service.

Hope it works

regards

suresh