[flexcoders] Re: Variations of sending arguments to a WebService in AS
Ben, thanks for your comments. I added that to my list of variations and it results in the same traceback as does my variation six -- that is, it generates an error saying that sendStrings (or arg0) was an unexpected parameter found in the input :(. However... without seeing the relevant portion of your WSDL and XSD I can't be positive that I did the mapping in the exact same fashion, so if you could post the relevant portions that would be great. Thanks for the help. --Kaleb --- In flexcoders@yahoogroups.com, "ben.clinkinbeard" <[EMAIL PROTECTED]> wrote: > > I didn't read through all of your code but here is the method I have > been using with success. > > var op:Operation = service.getOperation("GetDataByGrouping") as Operation; > op.resultFormat = "e4x"; > // temp object to store arguments > var args:Object = new Object(); > args.groupingRequests = new Object(); > args.groupingRequests.GroupName = "RPRToolStaticData"; > > op.arguments = args; > service.GetDataByGrouping(); > > HTH, > Ben > > --- In flexcoders@yahoogroups.com, "kaleb_pederson" wrote: > > > > Hello, > > > > I'm trying to send some arguments to a webservice, but every > > variation I have tried other than generating the XML from scratch > > keeps failing (eg. sends an empty message body). Relevant parts of > > the WSDL are as follows: > > > > > > > > > > > > > name="parameters"> > > > > ... > > > > > > > > > > > > And from the XSD: > > > >> xmlns:ns3="http://server.webservices.tutorials.wakaleo.com/"; > > type="ns3:sendStrings" name="sendStrings"> > > > > > > > >> maxOccurs="unbounded"> > > > > > > > >> xmlns:ns4="http://server.webservices.tutorials.wakaleo.com/"; > > type="ns4:sendStringsResponse" > > name="sendStringsResponse"> > > > > > > > >> maxOccurs="unbounded"> > > > > > > > > Based on everything that I have been able to find in the > > documentation and on flexcoders, there are a number of different > > ways to send requests to the web service, so I tried each of the > > ones that I could find. > > > > However, only one of them succeeds -- specifically, the case where I > > build an XMLDocument from scratch and send it. All the other cases > > fail -- that is, they do not pass *any* arguments to the web > > service. > > > > The following TestCase (which is kind of long) shows the different > > variations that have been tried. The main things of interest are > > the variationN functions in the beginning of the class as these test > > the different ways to call the web service. If TestCase had an > > asyncSetup function the sample case could be quite a bit shorter... > > (but perhaps I'll work on that next): > > > > package code > > { > > import flash.events.Event; > > import flexunit.framework.TestCase; > > import mx.rpc.events.FaultEvent; > > import mx.rpc.events.ResultEvent; > > import mx.rpc.soap.LoadEvent; > > import mx.rpc.soap.mxml.WebService; > > import flash.utils.describeType; > > import mx.rpc.events.AbstractEvent; > > import mx.rpc.AbstractOperation; > > import flash.xml.XMLDocument; > > import flash.xml.XMLNode; > > > > > > public class TestSendStrings extends TestCase > > { > > private var ws:WebService; > > private static const SERVICE_TIMEOUT:Number = 2000; > > private var wsdlUrl:String > > = "http://192.168.1.108:8080/stockquotes/stock_quote?wsdl";; > > private var responseHandler:String; > > private var sendStringsFunc:String; > > > > // these are the different variations that I have tried. Of > > these > > // different variations, variation9 succeeds because I have hand > > // crafted a valid message body (NOTE that variation 8 fails and > > // that the only difference is XML vs. XMLDocument). variation6 > > // generates a fault, so it fails for a different reason than > > // some of the others > > private function variation1():void { > > trace('variation1'); > > var op:AbstractOperation = ws.getOperation('sendStrings'); > > op.arguments = new Array('variation','one'); > > op.send(); > > } > > > > private function variation2():void { > > trace('variation2'); > > ws.sendStrings.arguments = new Array('variation','two'); > > ws.sendStrings.send(); > > } > > > > private function variation3():void { > > trace('variation3'); > > ws.sendStrings.send(new Array('variation','three')); > > } > > > > private function variation4():void { > > trace('variation4'); > > ws.sendStrings.send('variation','four'); > > } > > > > private function variation5():void { > > trace('variation5'); > > ws.sendStrings('variation','five'); > > } > > > > private function variation6():void { > > // this function results in a fault event: > > // Un
[flexcoders] Re: Variations of sending arguments to a WebService in AS
I didn't read through all of your code but here is the method I have been using with success. var op:Operation = service.getOperation("GetDataByGrouping") as Operation; op.resultFormat = "e4x"; // temp object to store arguments var args:Object = new Object(); args.groupingRequests = new Object(); args.groupingRequests.GroupName = "RPRToolStaticData"; op.arguments = args; service.GetDataByGrouping(); HTH, Ben --- In flexcoders@yahoogroups.com, "kaleb_pederson" <[EMAIL PROTECTED]> wrote: > > Hello, > > I'm trying to send some arguments to a webservice, but every > variation I have tried other than generating the XML from scratch > keeps failing (eg. sends an empty message body). Relevant parts of > the WSDL are as follows: > > > > > > name="parameters"> > > ... > > > > > > And from the XSD: > >xmlns:ns3="http://server.webservices.tutorials.wakaleo.com/"; > type="ns3:sendStrings" name="sendStrings"> > > > >maxOccurs="unbounded"> > > > >xmlns:ns4="http://server.webservices.tutorials.wakaleo.com/"; > type="ns4:sendStringsResponse" > name="sendStringsResponse"> > > > >maxOccurs="unbounded"> > > > > Based on everything that I have been able to find in the > documentation and on flexcoders, there are a number of different > ways to send requests to the web service, so I tried each of the > ones that I could find. > > However, only one of them succeeds -- specifically, the case where I > build an XMLDocument from scratch and send it. All the other cases > fail -- that is, they do not pass *any* arguments to the web > service. > > The following TestCase (which is kind of long) shows the different > variations that have been tried. The main things of interest are > the variationN functions in the beginning of the class as these test > the different ways to call the web service. If TestCase had an > asyncSetup function the sample case could be quite a bit shorter... > (but perhaps I'll work on that next): > > package code > { > import flash.events.Event; > import flexunit.framework.TestCase; > import mx.rpc.events.FaultEvent; > import mx.rpc.events.ResultEvent; > import mx.rpc.soap.LoadEvent; > import mx.rpc.soap.mxml.WebService; > import flash.utils.describeType; > import mx.rpc.events.AbstractEvent; > import mx.rpc.AbstractOperation; > import flash.xml.XMLDocument; > import flash.xml.XMLNode; > > > public class TestSendStrings extends TestCase > { > private var ws:WebService; > private static const SERVICE_TIMEOUT:Number = 2000; > private var wsdlUrl:String > = "http://192.168.1.108:8080/stockquotes/stock_quote?wsdl";; > private var responseHandler:String; > private var sendStringsFunc:String; > > // these are the different variations that I have tried. Of > these > // different variations, variation9 succeeds because I have hand > // crafted a valid message body (NOTE that variation 8 fails and > // that the only difference is XML vs. XMLDocument). variation6 > // generates a fault, so it fails for a different reason than > // some of the others > private function variation1():void { > trace('variation1'); > var op:AbstractOperation = ws.getOperation('sendStrings'); > op.arguments = new Array('variation','one'); > op.send(); > } > > private function variation2():void { > trace('variation2'); > ws.sendStrings.arguments = new Array('variation','two'); > ws.sendStrings.send(); > } > > private function variation3():void { > trace('variation3'); > ws.sendStrings.send(new Array('variation','three')); > } > > private function variation4():void { > trace('variation4'); > ws.sendStrings.send('variation','four'); > } > > private function variation5():void { > trace('variation5'); > ws.sendStrings('variation','five'); > } > > private function variation6():void { > // this function results in a fault event: > // Unexpected parameter 'sendStrings' found in input > arguments. > trace('variation6'); > var op:AbstractOperation = ws.getOperation('sendStrings'); > op.arguments = {sendStrings:{arg0:new > Array('variation','six')}}; > op.send(); > } > > private function variation7():void { > trace('variation7'); > var op:AbstractOperation = ws.getOperation('sendStrings'); > op.send({sendStrings:{arg0:new Array('variation','six')}}); > } > > private function variation8():void { > trace('variation8'); > var xml:XML = new XML(' xmlns:ns1="http://server.webservices.tutorials.wakaleo.com/";>' + > 'variationeight' + > ''); > var op:AbstractOperation = ws.getOperation('sendStrings'); > op.send(xml); > } > > private function variation9():void { >