Monday, 23 September 2013

How to call a Web Service For Cross Domain in FLEX




Step1: 
Set The Paths For the Java and Blazeds.
                 CATALINA_HOME: C:\blazeds-turnkey-4.0.0.14931\tomcat.
             Java Paths: 
                 Java_Home: C:\Program Files\Java\jdk1.7.0_03;
                 path: C:\Program Files\Java\jdk1.7.0_03\bin; 

Step2:
In  C:\blazeds-turnkey-4.0.0.14931\tomcat\Webapps  create a folder with a some name
And then go to samples folder copy WEB_INF folder in that folder and paste that WEB_INF folder in
Folder which you created.

Step3:
 WEB-INF must contain
classes,flex,jsp,lib,src folders and web.xml file.

Step4:
Create A project in  Flash Builder by selecting the Blazeds server with
                Root Folder:       C:\blazeds-turnkey-4.0.0.14931\tomcat\webapps\folder Name   
                Root URL:          http://localhost:8400/Webconfigfile\ folder Name  
                Context Root:    \ folder Name

Step5:
In Flex Application Declaration block
<s:WebService  id="WBSample"
                             destination="ws-catalog"
                             useProxy="true"
                             result="WBSample_resultHandler(event)"
                             fault="WBSample_faultHandler(event)"
 load="WBSample.CelsiusToFahrenheit(12)" />


Step6:
 In the folder which you Created open WEB_INF folder --> flex folder --> proxy-config file with notepad.
                In that set the destination tag like this below

<destination id="ws-catalog" 
 <properties>
<wsdl>http://www.w3schools.com/webservices/tempconvert.asmx?wsdl</wsdl>
 <soap>*</soap>
</properties>
 <adapter ref="soap-proxy"/>
 </destination>


  In that destination id and destination  attribute in Webservice tag should be same.  

                               Without server directly from flex:
 Step1:
In Flex Application Declaration block 
     <s:WebService id="wsSaveEmployee" 
wsdl="http://www.w3schools.com/webservices/tempconvert.asmx?wsdl
          showBusyCursor="true">
          <s:operation name="CelsiusToFahrenheit"
                   resultFormat="object"
                   result="saveChangePwdresult(event)" 
fault="saveChangePwdfault(event)"/> </s:WebService>
 Step2:
 CelsiusToFahrenheit is the method name in WebService.           
              wsSaveEmployee.CelsiusToFahrenheit.send(24);
 
 

No comments: