1 Reply Latest reply on Feb 18, 2007 5:44 PM by Cameron74

    HTTP POST with XML with HTTPService

    cgallemore23
      Hi,

      I need to be able to send an HTTP POST request to a server I have on Tomcat. In the body of the POST Request I need to have the following:

      <setView domain="someDomain" view="macro" />

      We have tried the following using the HTTPService, but with no such luck

      <mx:HTTPService id="setViewHTTPService" url="{serverURL}" resultFormat="object" contentType="application/xml" method="POST">
      <mx:request>
      <setView domain="abc" view="xyz" />
      </mx:request>
      </mx:HTTPService>

      Is there a way for us to specify the body of the HTTP Post using HTTPService, or a different class for that matter.
        • 1. Re: HTTP POST with XML with HTTPService
          Cameron74
          var variables:URLVariables = new URLVariables("name=Franklin");
          //or variables.name = "Franklin";
          var request:URLRequest = new URLRequest();
          request.url = " http://www.[yourdomain
          request.method = URLRequestMethod.POST;
          request.data = variables;
          var loader:URLLoader = new URLLoader();
          loader.dataFormat = URLLoaderDataFormat.VARIABLES;
          loader.addEventListener(Event.COMPLETE, completeHandler);
          try
          {
          loader.load(request);
          }
          catch (error:Error)
          {
          trace("Unable to load URL");
          }

          function completeHandler(event:Event):void
          {
          trace(event.target.data.welcomeMessage);
          }

          This is in the help documentation and what I generally use.