# Passing values to a webService

**URL:** https://forum.kirupa.com/t/passing-values-to-a-webservice/292368
**Category:** flash
**Created:** [July 13, 2009, 4:33pm UTC](https://forum.kirupa.com/t/passing-values-to-a-webservice/292368 "2009-07-13T16:33:18Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![JBird1000](https://avatars.discourse-cdn.com/v4/letter/j/f19dbf/32.png) [@JBird1000](https://forum.kirupa.com/u/JBird1000)
#### Post date: [July 13, 2009, 4:33pm UTC](https://forum.kirupa.com/t/passing-values-to-a-webservice/292368/1 "2009-07-13T16:33:18Z")

</div>

I have had some help building this code to send a email… the person helping me on the web ran this code and got this trace returned:

OK. So now it gets interesting. LOL. I just sent a message to YOUR service and got this:

SOAP (mx.messaging.messages::SOAPMessage)#0  
body = “\<SOAP-ENV:Envelope xmlns:SOAP-ENV=“[http://schemas.xmlsoap.org/soap/envelope/](http://schemas.xmlsoap.org/soap/envelope/)” xmlns:s=“[http://www.w3.org/2001/XMLSchema](http://www.w3.org/2001/XMLSchema)” xmlns:xsi=“[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)”\>  
\<SOAP-ENV:Body\>  
\<tns:SendMessageUsingGmail xmlns:tns=“[http://myURL/](http://myURL/)”\>  
\<tns:authKey\>password\</tns:authKey\>  
\<tns:to\>[someone@somwhere.com](mailto:someone@somwhere.com)\</tns:to\>  
\<tns:from\>[someone@somwhere.com](mailto:someone@somwhere.com)\</tns:from\>  
\<tns:subject\>test message\</tns:subject\>  
\<tns:body\>this is a test message\</tns:body\>  
\</tns:SendMessageUsingGmail\>  
\</SOAP-ENV:Body\>  
\</SOAP-ENV:Envelope\>”  
clientId = “DirectHTTPChannel0”  
contentType = “text/xml; charset=utf-8”  
destination = “DefaultHTTP”  
headers = (Object)#1  
DSEndpoint = “direct\_http\_channel”  
httpHeaders = (Object)#2  
SOAPAction = ““[http://myURL/SendMessageUsingGmail](http://myURL/SendMessageUsingGmail)””  
messageId = “FCFD82FB-626C-B9CB-E7F7-658F4C95E4E3”  
method = “POST”  
recordHeaders = false  
timestamp = 0  
timeToLive = 0  
url = “[http://myURL/services/gmailmailer.asmx](http://myURL/services/gmailmailer.asmx)”  
ACTION SendMessageUsingGmail  
RESULT OK

I run The code and i get this returned…

SOAP (mx.messaging.messages::SOAPMessage)#0  
body = “\<SOAP-ENV:Envelope xmlns:SOAP-ENV=“[http://schemas.xmlsoap.org/soap/envelope/](http://schemas.xmlsoap.org/soap/envelope/)” xmlns:s=“[http://www.w3.org/2001/XMLSchema](http://www.w3.org/2001/XMLSchema)” xmlns:xsi=“[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)”\>  
\<SOAP-ENV:Body\>  
\<tns:SendMessageUsingGmail xmlns:tns=“[http://myURL/](http://myURL/)”\>password\</tns:SendMessageUsingGmail\>  
\</SOAP-ENV:Body\>  
\</SOAP-ENV:Envelope\>”  
clientId = “DirectHTTPChannel0”  
contentType = “text/xml; charset=utf-8”  
destination = “DefaultHTTP”  
headers = (Object)#1  
DSEndpoint = “direct\_http\_channel”  
httpHeaders = (Object)#2  
SOAPAction = ““[http://myURL/SendMessageUsingGmail](http://myURL/SendMessageUsingGmail)””  
messageId = “1D37E110-48B7-AD56-CA4F-74DF9F1FB08E”  
method = “POST”  
recordHeaders = false  
timestamp = 0  
timeToLive = 0  
url = “[http://myURL/services/gmailmailer.asmx](http://myURL/services/gmailmailer.asmx)”  
ACTION SendMessageUsingGmail  
RESULT [object Object]

CAN ANYONE tell me why i am getting “Result [Object object]” and why its not seperating the string peramiters when i run it… THis is the code…

import mx.rpc.soap._;  
import mx.core._;  
import mx.rpc.events._;  
import mx.rpc._;  
import mx.messaging.messages.SOAPMessage;

var tf:TextField = addChild(new TextField()) as TextField; tf.width=500; tf.height=400; tf.wordWrap=true; var fmt:TextFormat = new TextFormat(); fmt.font="\_typewriter"; tf.defaultTextFormat=fmt;

// change serviceUri  
var serviceUri:String = (“[http://myURL.com/services/gmailmailer.asmx?WSDL](http://myURL.com/services/gmailmailer.asmx?WSDL)”);

var ws:WebService = new WebService();  
ws.addEventListener(LoadEvent.LOAD, onWSDL);  
ws.addEventListener(FaultEvent.FAULT, onWebServiceFault);  
ws.addEventListener(ResultEvent.RESULT, onWebServiceData);  
ws.wsdl = serviceUri;  
ws.loadWSDL();

function traceIt(… args)  
{  
tf.appendText(args.join(" ") + "  
");  
trace.apply(null,args);  
}

function onWSDL(event:Event):void {

var methodName:String = (“SendMessageUsingGmail”);  
var key:String = (“password”);  
var to:String = ("someone@somwhere.com");  
var from:String = ("someone@somwhere.com");  
var subject:String = (“test message”);  
var body:String = (“this is a test message”);

var f:\* = ws[methodName]; // returns an Operation object  
if(f != null){  
f.send (key,to,from,subject,body);  
}  
}

function onWebServiceFault(event:FaultEvent):void { traceIt(‘fault!:’ + event); if(event.token != null && event.token.message != null) {  
traceIt(“SOAP”, event.token.message);  
var action:String = (event.token.message as SOAPMessage).getSOAPAction();  
traceIt(“ACTION”, action.substring(action.lastIndexOf("/")+1,action.length-1));  
}  
}

function onWebServiceData(event:ResultEvent):void { traceIt(“SOAP”, event.token.message); var action:String = (event.token.message as SOAPMessage).getSOAPAction(); traceIt(“ACTION”, action.substring(action.lastIndexOf("/")+1,action.length-1));  
traceIt(“RESULT”, event.result);  
}

LOL im in way over my head here… I just need a quiz i built to send answers to a instructor when students take the quiz…
