Foros del Web » Creando para Internet » Flash y Actionscript »

consumir web service NET desde actionscript

Estas en el tema de consumir web service NET desde actionscript en el foro de Flash y Actionscript en Foros del Web. Hola gente que tal. Bueno les comento mi tema: Soy desarrollador C#, estoy empezando una web, y he decidido usar flex en el lado cliente, ...
  #1 (permalink)  
Antiguo 02/10/2006, 10:26
Avatar de gualicho  
Fecha de Ingreso: enero-2005
Ubicación: Capital Federal - Argentina
Mensajes: 55
Antigüedad: 19 años, 3 meses
Puntos: 0
consumir web service NET desde actionscript

Hola gente que tal. Bueno les comento mi tema:
Soy desarrollador C#, estoy empezando una web, y he decidido usar flex en el lado cliente, y C# de backend. La intercomunicacion seria a traves de webservices. El tema es el siguiente, flex, al crear el objeto WebService, me pide el "uri", que segun creo es la direccion del wsdl, que vendria a ser: "http://localhost/web/servicio.asmx?wsdl" no? o bien "http://tempuri.org/operacion"? Tengo una confusion con eso, porque el servicio todavia no lo tengo alojado en la web, sino localmente, y pienso que si pongo "play" (debug) en el visual studio, me carga el webservice, y creo que deberia estar disponible para accederlo, sin embargo, en actionscript me tira la excepcion de que no encuentra el wsdl... probe con tempuri, localhost, etc pero no hay caso.
Alguno hizo esto o sabe de alguna paginola con algun ejemplo copado? ya que no hay mucho sobre flex 2 todavia... y si bien la documentacion es bastante completa, no es la sintaxis de flex lo que me frena sino algun problema de configuracion seguramente.

Saludos y muchas gracias.
__________________

ASUS A7N8X-E Deluxe
AMD Semprom 2200 + (1.5 ghz) FSB 333
2 x 512 mb Kingston ddr 400 en dual channel
ATI Radeon 9250 (128 mb / 64 bits)
HD SAMSUNG SATA 120 gb
HD HITACHI IDE 80 gb

SO: Win XP, Debian Sarge
  #2 (permalink)  
Antiguo 02/10/2006, 10:53
Avatar de TMeister
Crazy Coder
 
Fecha de Ingreso: enero-2002
Ubicación: En la Oficina
Mensajes: 2.880
Antigüedad: 22 años, 3 meses
Puntos: 193
Este es un buen sitio para comenzar

http://livedocs.macromedia.com/flex/...=00001126.html
  #3 (permalink)  
Antiguo 02/10/2006, 11:01
Avatar de gualicho  
Fecha de Ingreso: enero-2005
Ubicación: Capital Federal - Argentina
Mensajes: 55
Antigüedad: 19 años, 3 meses
Puntos: 0
Hola Meister, bueno gracias, estuve ya leyendo esa documentacion, pero por eso, creo que mi problema pasa por otro lado, ya que mi problema es el bendito "path not found" cuando quiero cargar el wsdl... no es sobre la sintaxis de flex.

Si alguien hizo esto algunas vez por favor digame.
Gracias, saludos.
__________________

ASUS A7N8X-E Deluxe
AMD Semprom 2200 + (1.5 ghz) FSB 333
2 x 512 mb Kingston ddr 400 en dual channel
ATI Radeon 9250 (128 mb / 64 bits)
HD SAMSUNG SATA 120 gb
HD HITACHI IDE 80 gb

SO: Win XP, Debian Sarge
  #4 (permalink)  
Antiguo 02/10/2006, 14:32
Avatar de TMeister
Crazy Coder
 
Fecha de Ingreso: enero-2002
Ubicación: En la Oficina
Mensajes: 2.880
Antigüedad: 22 años, 3 meses
Puntos: 193
Oks.

Bien. lo que puedes hacer es comprobar si realmente tu localhost regresa algo. puedes usar el Tag de MXML traceTarget que es un Debugger detallado de todo lo que pasa en tu aplicacion algo asi.


Código HTML:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
	<mx:Script>
		<![CDATA[
			import mx.events.*
			private function onResultOK(event:Event):void
			{
				trace(event)
			}
			private function onResultFault(fault:Event):void
			{
				trace(fault)
			}
		]]>
	</mx:Script>
	<mx:TraceTarget />
	<mx:WebService wsdl="http://localhost:port/path/to/your/file.wsdl" id="miConexion">
	    <mx:operation result="onResultOK(event)" fault="onResultFault(event)" name="Handler"/>
	</mx:WebService>
</mx:Application> 
No olvides correr tu aplicacion en modo Debug

Saludos!!
  #5 (permalink)  
Antiguo 02/10/2006, 16:45
Avatar de TMeister
Crazy Coder
 
Fecha de Ingreso: enero-2002
Ubicación: En la Oficina
Mensajes: 2.880
Antigüedad: 22 años, 3 meses
Puntos: 193
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!!
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:01.