Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Webservice configuration  (Read 7618 times)
clebrun
Newbie
*
Posts: 2


View Profile Email
« on: May 05, 2010, 11:25:04 »

Hi,

I am building my first PureMVC app, and I am more familiar with Mate.

My app is reading a XML config file at startup. This XML config file contains the location of a webservice WSDL. Then, my app has to query some web methods  of this webservice.

Here are my question: I am implementing a Proxy per WebMethod, but in each of these Proxy I am initializing a WebService (Load WSDL ...) using the config oject I pass in the notification.
Is there a way to avoid this ? By initializing only one WebService and using it in the differents Proxy ?

Thanks !
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: May 08, 2010, 07:54:43 »

First, is it really necessary to have separate proxies for each method? Usually the Proxies are one per data type. So if you had several methods for CRUD functionality for an object type, you'd handle them all in one Proxy.

Now if you have lots of disparate data types being managed by the same service, then yes, you'd need multiple Proxies talking to the same service.

In that case you probably want to create a Delegate class that has the service and method definitions and have each Proxy instantiate a Delegate and use it for making the calls.
You can see an example of a Delegate in the Cafe Townsend Flex Demo.

-=Cliff>
Logged
clebrun
Newbie
*
Posts: 2


View Profile Email
« Reply #2 on: May 11, 2010, 12:18:40 »

Thanks for your answer.

I need separates proxies because even if all web methods return XML, their meaning is different :

The first method called is to authenticate the user. So I after receiving the result, I only need to send an event to know if authenticate succeed or not.
The other methods called return XML data that I parse to create different VO, depending of the called method.


About my "problem" of webservice instantiation, here is how I did :
- First, using a ConfigProxy, I read from a config file the webservice URL
- In this ConfigProxy, when I receive the result, I instantiate a WebserviceProxy with the received URL
- Then, in the other proxies, I retrieve this WebServiceProxy and use it to call the different web methods

But I am not sure it is the best practice ...
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: May 11, 2010, 01:18:43 »

This will work. It is essentially implementing a Delegate in a Proxy. But if there are multiple calls that may go out at once you need to manage it closely to ensure the responses go back to the original caller. This is where the Delegate pattern is a little better, since each Proxy has its own Delegate instance with its own service instance.

-=Cliff>
Logged
Pages: [1]
Print