Professional Web Applications Themes

Basic Example Needed To Communicate With ASP.NET 2.0 Web Service - Macromedia Flex General Discussion

First a little background. I'm trying to access a .NET 2.0 Web Service from Flex. I'm very new to Flex and am looking into implementing it during my next website deployment in my current position if I can get it work for my needs. That said, I've tried every possible example online (through Flex.org, several blog responses, etc) to connect to a .NET web service and nothing works. I'm working w/both the Flex 2.0 SDK and the Flex 3 Beta 1 SDK and neither have worked in this scenario. The web service I have built and deployed locally can be ...

  1. #1

    Default Basic Example Needed To Communicate With ASP.NET 2.0 Web Service

    First a little background. I'm trying to access a .NET 2.0 Web Service
    from Flex. I'm very new to Flex and am looking into implementing it
    during my next website deployment in my current position if I can get
    it work for my needs. That said, I've tried every possible example
    online (through Flex.org, several blog responses, etc) to connect to
    a .NET web service and nothing works. I'm working w/both the Flex 2.0
    SDK and the Flex 3 Beta 1 SDK and neither have worked in this
    scenario. The web service I have built and deployed locally can be
    accessed from the localhost (I'm running IIS 5.1 on Win XP Pro SP2)
    and also can be accessed from other ASP.NET applications as tested.
    Evidently, I'm missing something here. When I run the swf file that is
    compiled from the mxml file, I get a blank screen w/"Waiting for
    localhost..." at the bottom of the browser (Firefox 2.0) window.
    Outside of the web service results, other controls (drop down lists,
    buttons, etc) in flex work fine for me. I need to get this to work w/o
    using Flex Data Services, etc. Heres the mxml code for one of the many
    examples that I can't get to work:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute" backgroundColor="yellow">
    <mx:WebService id="myService"
    wsdl="http://localhost/ASPNETWebServiceApp/Service.asmx?WSDL"
    load="myService.Greeting('SomeName')"
    showBusyCursor="true"/>

    <mx:Label text="{myService.Greeting.lastResult}"/>
    </mx:Application>

    Here's the very basic Web Method inside the Web Service (built in
    C#.NET 2005) that I'm trying to access:

    [WebMethod]
    public string Greeting(String strName)
    {

    return "Hello " + strName + "!";
    }

    Please dumn-down any responses pertaining to the Flex part as I may be
    missing something basic in Flex.

    Thanks for any assistance.
    E.

    emartinez.gt@gmail.com Guest

  2. #2

    Default Re: Basic Example Needed To Communicate With ASP.NET 2.0 Web Service

    This is a sample of flex code sending array of integers to web
    service. This should give you idea:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="vertical">

    <mx:Script>
    <![CDATA[
    import mx.collections.ArrayCollection;

    private function sendObject():void
    {
    var myArray:Array = new Array();
    var i:int;
    for (i = 0; i < int(countInput.text ); i++)
    {
    myArray[i] = valueInput.text + i;
    }
    dataService.SendArrayIntegers(myArray);
    }
    ]]>
    </mx:Script>

    <mx:WebService id="dataService" wsdl="http://localhost/Service.asmx?
    wsdl" showBusyCursor="true"/>

    <mx:VBox width="800" borderStyle="solid" borderThickness="1"
    backgroundColor="#eeeeee" height="276" horizontalAlign="center">
    <mx:Label text="Sending Arguments" fontSize="14"/>
    <mx:HBox>
    <mx:Label text="Value:"/><mx:TextInput id="valueInput" text="Value"/
    >
    </mx:HBox>
    <mx:HBox>
    <mx:Label text="Items #:"/><mx:TextInput id="countInput" text="10"/
    >
    </mx:HBox>
    <mx:Button label="Send Object" click="sendObject()"/>
    <mx:TextArea fontSize="12"
    text="{dataService.SendArrayIntegers.lastResult}" width="438"
    height="148"/>
    </mx:VBox>

    </mx:Application>

    mojeza Guest

  3. #3

    Default Re: Basic Example Needed To Communicate With ASP.NET 2.0 Web Service

    On Jul 6, 6:28 am, mojeza <naj...hotmail.com> wrote:
    > This is a sample offlexcode sending array of integers towebservice. This should give you idea:
    >
    > <?xml version="1.0" encoding="utf-8"?>
    > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    > layout="vertical">
    >
    > <mx:Script>
    > <![CDATA[
    > import mx.collections.ArrayCollection;
    >
    > private function sendObject():void
    > {
    > var myArray:Array = new Array();
    > var i:int;
    > for (i = 0; i < int(countInput.text ); i++)
    > {
    > myArray[i] = valueInput.text + i;
    > }
    > dataService.SendArrayIntegers(myArray);
    > }
    > ]]>
    > </mx:Script>
    >
    > <mx:WebService id="dataService" wsdl="http://localhost/Service.asmx?
    > wsdl" showBusyCursor="true"/>
    >
    > <mx:VBox width="800" borderStyle="solid" borderThickness="1"
    > backgroundColor="#eeeeee" height="276" horizontalAlign="center">
    > <mx:Label text="Sending Arguments" fontSize="14"/>
    > <mx:HBox>
    > <mx:Label text="Value:"/><mx:TextInput id="valueInput" text="Value"/
    >
    > </mx:HBox>
    > <mx:HBox>
    > <mx:Label text="Items #:"/><mx:TextInput id="countInput" text="10"/
    >
    > </mx:HBox>
    > <mx:Button label="Send Object" click="sendObject()"/>
    > <mx:TextArea fontSize="12"
    > text="{dataService.SendArrayIntegers.lastResult}" width="438"
    > height="148"/>
    > </mx:VBox>
    >
    > </mx:Application>

    Thanks for your reply. It turns out that a friend of mine lead me to a
    utility that checks the SOAP messages coming from Flex, etc (http://
    [url]www.freedownloadscenter.com/Network_and_Internet/Network_Management_Tools/IE_HTTP_yzer_Download.html[/url])
    and the Flex side was looking for a file called 'crossdomain.xml' at
    localhost. So I created this file and added in:
    <?xml version="1.0"?>
    <cross-domain-policy>
    <allow-access-from domain="*" />
    </cross-domain-policy>
    and placed it at C:\Inetpub\wwwroot\ and everything started working.

    Regards,

    Enrique Martinez

    EMartinez Guest

Similar Threads

  1. Flex communicate with Web Service is slow
    By TigerLittle in forum Macromedia Flex General Discussion
    Replies: 17
    Last Post: June 28th, 07:27 PM
  2. Unable to communicate with SSL Web Service using X509 Client Cert
    By gardavis in forum ASP.NET Web Services
    Replies: 1
    Last Post: July 3rd, 12:50 AM
  3. simple examples needed with sql2000, asp.net, visual basic
    By Ryan McBride in forum ASP.NET Data Grid Control
    Replies: 5
    Last Post: December 14th, 01:05 PM
  4. Help needed with basic Perl math commands
    By \Dandy\ Randy in forum PERL Miscellaneous
    Replies: 4
    Last Post: July 27th, 05:11 AM
  5. Really basic help needed with mouse overs
    By w.robson.dslw@oneteldsl.net in forum Macromedia Flash
    Replies: 2
    Last Post: July 20th, 04:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139