How to avoid redeclaring your web service interface?
hi there,
how can 1 avoid having redeclare wsdl interface on each mxml page accessed? want declare web service , operation has once , include in component use access/update data.
i new flex may obviouse other not me. tried including in own mxml file , using normal component include tag include it. errors not being able access webservice via id.
e.g.
error: access of undefined property webservice.
[mxmlc] webservice.getsiteoptions.send();
thanks
how can 1 avoid having redeclare wsdl interface on each mxml page accessed? want declare web service , operation has once , include in component use access/update data.
i new flex may obviouse other not me. tried including in own mxml file , using normal component include tag include it. errors not being able access webservice via id.
e.g.
error: access of undefined property webservice.
[mxmlc] webservice.getsiteoptions.send();
thanks
the solution place web definition in separate file , use "include" functionality of defining own namespace in xml. include in main application file.
eg
<mx:panel
xmlns:mx=" http://www.adobe.com/2006/mxml"
xmlns:webservice="webservice.*"
width="100%"
height="100%"
title="reports menu"
creationcomplete="oninit();" >
on main application page include web service file
<webservice:webservices id="services"/>
the webservices.mxml file contain definitions.
<?xml version="1.0" encoding="utf-8"?>
<mx:canvas xmlns:mx=" http://www.adobe.com/2006/mxml"
height="0"
visible="false">
<mx:script>
<![cdata[
import mx.rpc.soap.mxml.webservice;
import mx.rpc.events.faultevent;
import mx.controls.alert;
[bindable]
public var webservicewsdl:string =" http://127.0.0.1:8080/jumpingbean/services/addwebservice?wsdl";
public function onservicefault(evt:faultevent):void
{
var err:error = new error(evt.fault.faultcode + " , " + evt.fault.faultstring);
parentapplication.showerror(err);
}
public function onsuccess(evt:event):void
{
alert.show(evt.tostring());
}
]]>
</mx:script>
<!-- ======================================== -->
<!-- remote services -->
<!-- ======================================== -->
<mx:webservice id="webservice" wsdl="{this.webservicewsdl}" service="valueaddwebservice" port="appwebservicehttpport" fault="onservicefault(event)" showbusycursor="true" >
etc
in child components can refer component doing "parentapplication.services.webservice"
eg
<mx:panel
xmlns:mx=" http://www.adobe.com/2006/mxml"
xmlns:webservice="webservice.*"
width="100%"
height="100%"
title="reports menu"
creationcomplete="oninit();" >
on main application page include web service file
<webservice:webservices id="services"/>
the webservices.mxml file contain definitions.
<?xml version="1.0" encoding="utf-8"?>
<mx:canvas xmlns:mx=" http://www.adobe.com/2006/mxml"
height="0"
visible="false">
<mx:script>
<![cdata[
import mx.rpc.soap.mxml.webservice;
import mx.rpc.events.faultevent;
import mx.controls.alert;
[bindable]
public var webservicewsdl:string =" http://127.0.0.1:8080/jumpingbean/services/addwebservice?wsdl";
public function onservicefault(evt:faultevent):void
{
var err:error = new error(evt.fault.faultcode + " , " + evt.fault.faultstring);
parentapplication.showerror(err);
}
public function onsuccess(evt:event):void
{
alert.show(evt.tostring());
}
]]>
</mx:script>
<!-- ======================================== -->
<!-- remote services -->
<!-- ======================================== -->
<mx:webservice id="webservice" wsdl="{this.webservicewsdl}" service="valueaddwebservice" port="appwebservicehttpport" fault="onservicefault(event)" showbusycursor="true" >
etc
in child components can refer component doing "parentapplication.services.webservice"
More discussions in Flex (Read Only)
adobe
Comments
Post a Comment