5 Replies Latest reply on Jan 13, 2008 12:12 PM by bfd02886

    HTTPService parameters

    bfd02886
      I have a servlet on my application server that I am looking to call in Flex. I have an <mx:HTTPService> element coded and was using the clicked event of a button to trigger the send() in AS. I instantiated a variable of type Object and ran through the fields on my form to populate the Object variable and then pass that in the send() method. I've debugged the app and the Object variable is set with all my form values and it should be sending those to the servlet, but the servlet is not working.

      It is a registration process so the user would enter some demographics and it would insert a row in the database for that user.

      I've put the URL that I believe is being built based on the Object properties into my browser and it works fine. I then changed the HTTPService to hard code the URL parameters to make sure it is being called and that worked as well...actually sort of worked, I was expecting some XML back but that's another issue for later.

      Is there a limitation of how many parameters can be passed with an Object variable to an HTTPService? How can I check to see what is being received by the serlvet short of installing the application server on my machine and using localhost?

      Thanks in advance,
      Bryan
        • 1. Re: HTTPService parameters
          m_hartnett Level 3
          Here is your service definition:
          <mx:HTTPService id="LocationSaveService"
          url=" http://localhost:8090/flexmed/locationSave.flex"
          showBusyCursor="true"
          method="POST"
          id="locationSaveService/>

          var reqObj : Object = new Object();
          reqObj["parm1"] = "parm1Data";
          reqObj["parm2"] = "parm2Data"
          locationSaveService.send( reqObj );

          The reqObj is simply an object that has a bunch of properties.

          I do not believe there is a limitation with the POST method.
          I believe that the GET method has limitiation. Get is the default for the HTTPService object.


          Use post as the method
          • 2. Re: HTTPService parameters
            bfd02886 Level 1
            I tried using method="POST" and I'm getting the same results (or lack thereof). The HTTPService thinks it was successful as its calling the method in the result, but the data is not getting to the database.
            • 3. Re: HTTPService parameters
              m_hartnett Level 3
              If you post your code we can get a better idea.

              But basically, you look like your are on the right path.
              As long as you are creating an object with properties and assigining a value to the property and passing it to the send method Flex will do the rest.

              Other than scratching through log statements, you need to write some server code to log what is happening on the server after the request is made. That is the only way to see what is happening on the server.

              I don't know of any way to examine the URL that Flex generates using the send method and the requestObject.
              • 4. Re: HTTPService parameters
                bfd02886 Level 1
                I think I'll add some logging functionality to the servlets. That way I can see how the call is being sent via Flex.

                Thanks.
                • 5. Re: HTTPService parameters
                  bfd02886 Level 1
                  I added logging and it appears that using an Object to post the parameters to the url is not working. Why, I don't know, but I changed the code to just build a full url string with parameters and that seems to be working OK, so I use that for now.