1. Apply the service-wsdl.patch to your OFBIZ copy.
2. Export your service by add "export="true" in your service definition
file(services.xml), for example

<service name="getReverseAuctionPrice" engine="java" export="true"

             location=" ....
3. In the Flex mxml file, declare the web service

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:mx="library://ns.adobe.com/flex/halo"
               creationComplete="initApp()">
<fx:Declarations>
        <s:WebService id="serviceId"
                      wsdl="
http://localhost:8080/webtools/control/SOAPService/getReverseAuctionPrice?WSDL
"
                      useProxy="false">
            <s:operation name="getReverseAuctionPrice"
result="flashReverseAuctionData(event)"
                         fault="showError(event)">
                <s:request>
                    <period>{period}</period>
                    <runMode>{runMode}</runMode>
                    <itemId>{itemId}</itemId>
                    <participants>{participants}</participants>
                    <newestBidTime>{newestBidTime}</newestBidTime>
                </s:request>
            </s:operation>
        </s:WebService>
    </fx:Declarations>

flashReverseAuctionData and showError are the callback method. period
and runMode are the parameters which bind to properties of the class.
<fx:Script>
        [Bindable]
        private var itemId:String;
        [Bindable]
        private var participants:String;
...


4. Create the callback method called by Flex webservice component.

private function showError(event:FaultEvent):void {

            Alert.show(event.fault.faultString);
        }
5. Call the service

try {

                serviceId.getReverseAuctionPrice();
            } catch(ex:Error) {
                Alert.show(ex.message);
            }
6. Manipulate the result

private function flashReverseAuctionData(event:ResultEvent):void {

            var bidsData = JSON.decode(event.result.toString());
            if(bidsDataStore==null ){
                bidsDataStore= bidsData;
            }else{
                 //TODO
            }
        }

Using as3corelib to deal with JSON format data





On Tue, Feb 2, 2010 at 1:05 PM, Christopher Snow <
[email protected]> wrote:

> Hi Zhang,
>
> Would you be happy to provide some documentation on how to do this?
>
> Many thanks,
>
> Chris
>
>
> Zhang Shiqian wrote:
>
>> Ofbiz services can be exported as standard web services, you can use Flex
>> to
>> call the web services. We have developed some Flex components used in our
>> ofbiz applications run in this model, and introduced as3corelib to deal
>> with
>> JSON format data.
>>
>> On Tue, Feb 2, 2010 at 12:42 AM, Christopher Snow <
>> [email protected]> wrote:
>>
>>
>>
>>> We are not automatically exporting objects with REST.
>>>
>>> We are exporting some services with REST.  Each one has to be manually
>>> coded.
>>>
>>> It would be nice to develop a solution to automatically export objects
>>> (entities), perhaps this would be relatively trivial using the new
>>> "entity-auto" service (i.e. CRuD service)?
>>>
>>>
>>>
>>>
>>> Abdullah Shaikh wrote:
>>>
>>>
>>>
>>>> Yes, thats good to have a separate component to handle xml over http,
>>>> REST
>>>> in your case.
>>>>
>>>> But I am not getting how are forming the url's, because in REST, urls
>>>> represents a objects.
>>>>
>>>> For example :
>>>>
>>>> http://ofbiz/partymgr/party/1234 - will represent a party whose id is
>>>> 1234
>>>>
>>>> http://ofbiz/partymgr/party/1234/addrress/5678 - will represent the
>>>> address
>>>> whose id is 5678 of party 1234
>>>>
>>>> I guess its difficult to have this sort of thing considering the number
>>>> of
>>>> functionality already build in ofbiz.
>>>>
>>>> or are you using REST but not following the each url represents an
>>>> object.
>>>>
>>>>
>>>> Thanks,
>>>> Abdullah
>>>>
>>>> On Mon, Feb 1, 2010 at 9:23 PM, Christopher Snow <
>>>> [email protected]> wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> Sorry - just seen this.
>>>>> The approach we currently use is having a dedicated web app in ofbiz
>>>>> which
>>>>> is used to expose ofbiz services using REST (the organisation favors
>>>>> REST) .
>>>>>  We are using the jersey rest libraries.
>>>>>
>>>>> I believe our flex guy is using HTTPService to communicate with rest.
>>>>>
>>>>> Cheers,
>>>>>
>>>>> chris
>>>>>
>>>>>
>>>>> Abdullah Shaikh wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> Hi Chris,
>>>>>>
>>>>>> I don't want to use xml-rpc but instead would like to use Flex
>>>>>> HTTPService,
>>>>>> I guess xml-rpc would work with HTTPService.
>>>>>>
>>>>>> Basic idea is to create a xml over http communication between ofbiz &
>>>>>> any
>>>>>> other RIA, so that we can make ofbiz communicated with flex, gwt etc.
>>>>>>
>>>>>> I will have a look at the link provided.
>>>>>>
>>>>>> Thanks,
>>>>>> Abdullah
>>>>>>
>>>>>> On Mon, Feb 1, 2010 at 8:09 PM, Christopher Snow <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> Hi Abdullah,
>>>>>>>
>>>>>>> On my current project, we initially used xml-rpc using a flex xmlrpc
>>>>>>> library sent to me by Andrew Zeneski.
>>>>>>>
>>>>>>> We had tried using the new ofbiz soap implementation, but it didn't
>>>>>>> play
>>>>>>> nicely with flex.
>>>>>>>
>>>>>>> Have a look at XMLRPC in the faq:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> http://cwiki.apache.org/confluence/display/OFBIZ/FAQ+-+Tips+-+Tricks+-+Cookbook+-+HowTo
>>>>>>>
>>>>>>> If you want a more optimised communication between flex and ofbiz,
>>>>>>> you
>>>>>>> can
>>>>>>> try BlazeDS:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> http://langhua.org/portal/portal/default/OFBiz/OFBizBlazeDSModulePortletWindow?windowstate=maximized
>>>>>>>
>>>>>>> Cheers,
>>>>>>>
>>>>>>> Chris
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Abdullah Shaikh wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Hi All,
>>>>>>>>
>>>>>>>> I want to develop a flex application which will interact with ofbiz
>>>>>>>> using
>>>>>>>> xml.
>>>>>>>>
>>>>>>>> I just had a cursory view of xmlrpcclient & xmlserializer, has
>>>>>>>> anybody
>>>>>>>> done
>>>>>>>> this ? what will be the best way to have ofbiz output xml ?
>>>>>>>>
>>>>>>>> I have seen that GenericValue can be easily converted to xml form.
>>>>>>>>
>>>>>>>> The request can be in xml form or can be a normal http request, but
>>>>>>>> the
>>>>>>>> response from ofbiz should be in xml form, for example something
>>>>>>>> like
>>>>>>>> this,
>>>>>>>>
>>>>>>>> <Orders>
>>>>>>>> <Order id="1" status="Approved"/> - all the required fields
>>>>>>>> <Order id="2" status="Created"/>
>>>>>>>> </Orders>
>>>>>>>>
>>>>>>>> <Parties>
>>>>>>>> <Party firstname="abc" lastname="xyz"> - all the required fields
>>>>>>>> </Parties>
>>>>>>>>
>>>>>>>> This way we can have a flex application communicate with ofbiz using
>>>>>>>> xml
>>>>>>>> over http, I think flex don't understand json, so we need to go the
>>>>>>>> xml
>>>>>>>> way
>>>>>>>> and also the benefits of xml is that with this approach ofbiz can
>>>>>>>> interact
>>>>>>>> with any kind of RIA technology.
>>>>>>>>
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Abdullah
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>>
>>
>
>


-- 
-- 
Regards,

Zhang Shiqian

Wizitsoft Information Technology Ltd.
www.wizitsoft.com | Phone: (8610)6267 0653 ext 604 | Mobile: (86)13264158885

Reply via email to