<?xml version="1.0" encoding="utf-8"?>
<mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml" 
    layout="absolute" 
    creationComplete="onCreationComplete()"
    defaultButton="{ sendButton }" viewSourceURL="srcview/index.html">
    
    <mx:Script>
        <![CDATA[
            import mx.utils.ObjectUtil;
            import mx.rpc.events.FaultEvent;
            import mx.rpc.events.ResultEvent;
            import mx.rpc.soap.SOAPHeader;
            
            private function onCreationComplete() : void
            {
                //add the LicenseInfo parameters to the web service SOAP header
                var qName : QName = new QName( "http://ws.strikeiron.com", "LicenseInfo" );
                var licenseInfo : XML = <LicenseInfo>
                                            <RegisteredUser>
                                                <UserID>USERID</UserID>
                                                <Password>PASSWORD</Password>
                                            </RegisteredUser>
                                         </LicenseInfo>;
                
                var header : SOAPHeader = new SOAPHeader( qName, licenseInfo );
                ws.addHeader( header );
                sendData();
            }
            
            private function sendData() : void
            {
                ws.GetCensusInfoForZipCode.send( zipcode.text );
            }
            
            private function onResult( event : ResultEvent ) : void
            {
                output.text = "RESULT\n" + ObjectUtil.toString( event.result );
            }
            
            private function onFault( event : FaultEvent ) : void
            {
                output.text = "FAULT\n" + ObjectUtil.toString( event.fault );
            }
            
        ]]>
    </mx:Script>
    
    <mx:WebService id="ws" 
        wsdl="http://sdpws.strikeiron.com/sdpCensus?WSDL"
           useProxy="false">
        <mx:operation name="GetCensusInfoForZipCode" 
            result="onResult( event );"
            fault="onFault( event )" />
    </mx:WebService>
    
    <mx:Label text="ZipCode:" top="12" height="18" left="10"/>
    <mx:TextInput top="10" height="22" left="73" width="67" id="zipcode" text="20006" />
    <mx:Button label="Send" top="10" height="22" left="148" click="sendData()" id="sendButton" />
    
    <mx:TextArea top="38" bottom="10" left="10" right="10" id="output" editable="false" />
    
</mx:Application>