5 Replies Latest reply on Nov 20, 2007 3:09 PM by ntsiii

    Send input Data to as file and then to .net web service

      I am new to Flex2 and I have been developing in .net for a few years. I want to have a registration form which would send the information to an actionscript file, and then that information is sent to a .net web service. The web service is built, tested and working properly. I can't seem to get the right calls to the action script file. Here is what I have;

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      import flash.events.Event;
      <Users:UsersManagement id="NewUser"/>

      <mx:Form width="360" height="236" label="Registration" id="formRegistration" x="332" top="10">
      <mx:FormItem width="300" horizontalAlign="left" label="Username:">
      <mx:TextInput id="tbxUserName" width="200"/>
      <mx:FormItem width="300" horizontalAlign="left" label="Password:">
      <mx:TextInput id="tbxPassword" displayAsPassword="true" width="200"/>
      <mx:FormItem width="300" horizontalAlign="left" label="First Name:">
      <mx:TextInput id="tbxFirstName" width="200"/>
      <mx:FormItem width="300" horizontalAlign="left" label="Last Name:">
      <mx:TextInput id="tbxLastName" width="200"/>
      <mx:FormItem width="300" horizontalAlign="left" label="Zip Code:">
      <mx:TextInput id="tbxZipCode" width="200"/>
      <mx:FormItem width="300" horizontalAlign="left" label="Email:">
      <mx:TextInput id="tbxUserEmail" width="200"/>
      <mx:Button label="Submit" click="NewUser.NewUser(tbxUserName.text, tbxPassword.text, tbxFirstName.text, tbxLastName.text, tbxZipCode.text, tbxUserEmail.text)"/>


      Here is the actionscript file.

      package Users {

      import flash.system.Capabilities;

      import mx.rpc.soap.WebService;

      public class UsersManagement
      public function UserManagement()


      public function NewUser(UserName:String, Password:String, FirstName:String, LastName:String, ZipCode:String, UserEmail:String):void
      var IPAddress:String = flash.system.Capabilities.version;
      var OperatingSystem:String = flash.system.Capabilities.os;
      var UserLanguage:String = flash.system.Capabilities.language;
      var Browser:String = flash.system.Capabilities.playerType;
      var wsUsers:WebService = new WebService();
      wsUsers.wsdl = " http://localhost:49388/TestSite/Users.asmx";
      wsUsers.NewUser(UserName, Password, FirstName, LastName, ZipCode, UserEmail, SignUpDate, Active, LastLogin, IPAddress, Browser, OperatingSystem, UserLanguage);
      if(wsUers.NewUser.lastResult = "Success") {
      var Result:String = "Success";


      The errors are coming when trying to communicate the mxml file and the actionscript file. I just haven't been able to find a lot of information on how to do this. Most examples just dump the actionscript within the mxml which is not good programming. Any help would be greatly appreciated. Thanks, Mike
        • 1. Re: Send input Data to as file and then to .net web service
          ntsiii Level 3
          what errors?

          Is NewUser() getting called? Are the arguments populated correctly?

          Instead of calling the method inline, have the click reun a hanlder function so you can debug the method call.

          All data service calls in Flex are asynchronous and you cannot acces the return value in the same function in which you make the call. You must use a result event handler function.

          • 2. Re: Send input Data to as file and then to .net web service
            VitaltypeMike Level 1
            The error I received was;

            Severity and Description Path Resource Location Creation Time Id
            1046: Type was not found or was not a compile-time constant: UsersManagement. TranscriptionWiki/src TranscriptionWiki.mxml line 14 1195502824599 106

            I am not worried about the return value at the moment. Right now, I want to try and get the information entered all the way through to the database. I am new to actionscript 3.0 so I have been hitting up different websites and changing the code last night and all through today with no luck. It seems to get hung up between the mxml and the actionscript file. If there is a link to a better way to do this, or even one that works, I wouldn't mind seeing it. Thanks for your help, it is definately appreciated. Mike
            • 3. Re: Send input Data to as file and then to .net web service
              ntsiii Level 3
              Is that error meaningful to you? Is UsersManagement on of your classes?

              What is throwing the error?
              And what about my second and third questions?

              • 4. Re: Send input Data to as file and then to .net web service
                VitaltypeMike Level 1
                I went back last night and started a new project. I wanted to be able to accomplish 2 things before I could decide to use Flex/.net/SQL. First, send two numbers to a web service, add them together, return a result, and put the numbers and the total in the database. 2nd, I wanted to have a grid that reflected all the numbers and totals I entered. I spent over 8 hours on this last night and tried about 10 different examples and couldn't get a single one to work. I tried examples from lynda.com, totaltraining, adobe documentation, and countless blogs. The webservice works fine, I can enter numbers, it adds them, returns the total. I also tried two different versions of the information to populate the grid. One was an XML document and one was a populated datatable. But I couldn't get anything information to populate a grid in Flex. I stopped using an .as file and just had the webservice info within the script block in the .mxml file and that wouldn't work either. I can't paste the code in here because I tried so many examples it really seems hacked up. I just want to know if anyone has a link or a resource information to this type of scenarion.

                I want to use actionscript classes to seperate my code from the .mxml files. I need to communicate both ways with .net web services, and I need to be able to fill grids with information through a .net web service. I am considering putting my little test numbers web service online so someone could see what I am doing wrong. Any input would be appreciated. Thanks, Mike
                • 5. Re: Send input Data to as file and then to .net web service
                  ntsiii Level 3
                  If you have control of the server, and do not need to make your data service available to anonymous third parties, you don't need the discovery functionality provided by the wsdl. Consider using HTTPService instead of WebService. It is much simpler to code on both ends. (I have an asp.net example on www.cflex.net. I also have a simple WebService example there as well.)

                  Otherwise, you need to take your problem one step at a time. I'd advise creating an operation/method that returns hard coded values. Make that display in Flex. then add the parameter.

                  Have you successfully consumed ANY WebService in Flex yet? Do that first.