A ver aqui te dejo un Ejemplo comsumiendo un webService real
Código HTML:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()">
<mx:Script>
<![CDATA[
import mx.events.*
import flash.xml.*
public function init():void
{
miConexion.GetQuote.send()
}
public function onResultOK(event:Event):void
{
var data:XMLDocument = new XMLDocument();
data.parseXML(miConexion.GetQuote.lastResult);
trace("********************************************")
trace("****** El Servicio Regresa *****************")
trace(data.firstChild.firstChild.firstChild.firstChild)
trace("********************************************")
}
public function onResultFault(fault:Event):void
{
trace(fault)
}
]]>
</mx:Script>
<mx:TraceTarget />
<mx:WebService wsdl="http://www.swanandmokashi.com/HomePage/WebServices/QuoteOfTheDay.asmx?WSDL" id="miConexion">
<mx:operation name="GetQuote" result="onResultOK(event)" fault="onResultFault(event)" resultFormat="xml" makeObjectsBindable="true"/>
</mx:WebService>
</mx:Application>
En la consola de Debug veras algo asi:
Código:
[SWF] C:\Documents and Settings\Tmeist3r\Desktop\test\bin\test-debug.swf - 710,243 bytes after decompression
Registering schema namespace: http://www.w3.org/1999/XMLSchema
Registering schema namespace: http://www.w3.org/2000/10/XMLSchema
Registering schema namespace: http://www.w3.org/2001/XMLSchema
Registering schema namespace: http://schemas.xmlsoap.org/soap/encoding/
Registering schema namespace: http://xml.apache.org/xml-soap
Registering schema namespace: http://rpc.xml.coldfusion
'713C74E1-DE13-FD63-D0D7-0B24093975E4' producer set destination to 'DefaultHTTP'.
'104A9794-CD74-E5E0-5A23-0B2409F46B8E' producer set destination to 'DefaultHTTP'.
'direct_http_channel' channel endpoint set to http:
Creating WSDL object for http://www.swanandmokashi.com/HomePage/WebServices/QuoteOfTheDay.asmx?WSDL
'F9949AE5-A6BB-E8CE-CDB3-0B2409F48592' producer set destination to 'DefaultHTTP'.
Loading document http://www.swanandmokashi.com/HomePage/WebServices/QuoteOfTheDay.asmx?WSDL for destination 'DefaultHTTP'
'713C74E1-DE13-FD63-D0D7-0B24093975E4' producer sending message '21B52FBD-1D18-B176-5E40-0B2409F459DE'
'direct_http_channel' channel sending message:
(mx.messaging.messages::HTTPRequestMessage)#0
body = (Object)#1
clientId = (null)
contentType = "application/x-www-form-urlencoded"
destination = "DefaultHTTP"
headers = (Object)#2
httpHeaders = (Object)#3
messageId = "21B52FBD-1D18-B176-5E40-0B2409F459DE"
method = "GET"
recordHeaders = false
timestamp = 0
timeToLive = 0
url = "http://www.swanandmokashi.com/HomePage/WebServices/QuoteOfTheDay.asmx?WSDL"
'713C74E1-DE13-FD63-D0D7-0B24093975E4' producer connected.
Queueing SOAP operation GetQuote
'713C74E1-DE13-FD63-D0D7-0B24093975E4' producer acknowledge of '21B52FBD-1D18-B176-5E40-0B2409F459DE'.
Processing imports for location http://www.swanandmokashi.com/HomePage/WebServices/QuoteOfTheDay.asmx?WSDL
Parsing schemas
Registering schema namespace: http://swanandmokashi.com
Done parsing schemas: 2 ms
Done processing imports: 327 ms
Parsing services
Parsing individual services
Parsing service: QuoteofTheDay
Parsing binding: http://swanandmokashi.com::QuoteofTheDaySoap
Parsing portType: http://swanandmokashi.com::QuoteofTheDaySoap
Parsed portType: 1 ms
Parsed binding: 3 ms
Parsed service: 6 ms
Done parsing services: 7 ms
WSDL parse took 334 ms
WSDL loaded
Made SOAP Operation for GetQuote
Set active port in service stub: QuoteofTheDay:QuoteofTheDaySoap
Invoking previously queued calls GetQuote
Invoking SOAP operation GetQuote
Initializing SOAP operation GetQuote
Parsing message: http://swanandmokashi.com::GetQuoteSoapIn
Message name is GetQuoteSoapIn
Parsed message: 3 ms
Parsing message: http://swanandmokashi.com::GetQuoteSoapOut
Message name is GetQuoteSoapOut
Parsed message: 3 ms
Asynchronously invoking SOAP Operation: GetQuote
Encoding SOAP request envelope
Encoding SOAP request body
Encoded SOAP Operation request: <?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><SOAP-ENV:Body><GetQuote xmlns="http://swanandmokashi.com" /></SOAP-ENV:Body></SOAP-ENV:Envelope>
'713C74E1-DE13-FD63-D0D7-0B24093975E4' producer sending message '4A9DD83A-D6B4-B1BE-E4E0-0B240B4C5ADD'
'direct_http_channel' channel sending message:
(mx.messaging.messages::SOAPMessage)#0
body = "<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><SOAP-ENV:Body><GetQuote xmlns="http://swanandmokashi.com" /></SOAP-ENV:Body></SOAP-ENV:Envelope>"
clientId = "DirectHTTPChannel0"
contentType = "text/xml; charset=utf-8"
destination = "DefaultHTTP"
headers = (Object)#1
httpHeaders = (Object)#2
SOAPAction = ""http://swanandmokashi.com/GetQuote""
messageId = "4A9DD83A-D6B4-B1BE-E4E0-0B240B4C5ADD"
method = "POST"
recordHeaders = false
timestamp = 0
timeToLive = 0
url = "http://www.swanandmokashi.com/HomePage/WebServices/QuoteOfTheDay.asmx"
'713C74E1-DE13-FD63-D0D7-0B24093975E4' producer acknowledge of '4A9DD83A-D6B4-B1BE-E4E0-0B240B4C5ADD'.
Decoding SOAP response
Encoded SOAP response: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetQuoteResponse xmlns="http://swanandmokashi.com"><GetQuoteResult><QuoteOfTheDay>He who does not prefer exile to slavery is not free by any measure of freedom, truth and duty.</QuoteOfTheDay><Author>Kahlil Gibran</Author></GetQuoteResult></GetQuoteResponse></soap:Body></soap:Envelope>
Decoding SOAP response envelope
Decoded SOAP response into result [0 millis]
********************************************
****** El Servicio Regresa *****************
He who does not prefer exile to slavery is not free by any measure of freedom, truth and duty.
********************************************
[Unload SWF] C:\Documents and Settings\Tmeist3r\Desktop\test\bin\test-debug.swf
Saludos!!