Dear All, I have a SOAP server running with Rails that works like a charm, until I try to pass in an array as a parameter. So, for example, suppose I have an api method that looks like this: api_method :list_processor, :expects => [[:string]], :returns => [:string] (take in an array of strings, return a string) And my method looks like this: def list_processor(list) list.each {|item| . . .} [...] end When I call that method from a (ruby) client, I get an error like this: `list_processor'': undefined method `each'' for #<SOAP::Mapping::Object:0xb74f9920> (NoMethodError) Which looks to me like it loses the type information and casts it into a generic SOAP object of some kind. How do I deal with this? Do I have to manually coerce the object back into an array? Can ActionWebService handle a simple array like this? The wsdl successfully identifies the parameter as a StringArray. Steve -- Stephen Ramsay Assistant Professor Department of English University of Georgia email: sramsay-zyaWFcxYZ9U@public.gmane.org web: http://cantor.english.uga.edu/ PGP Public Key ID: 0xA38D7B11
On 8/13/05, sramsay-zyaWFcxYZ9U@public.gmane.org <sramsay-zyaWFcxYZ9U@public.gmane.org> wrote:> Do I have to manually coerce the object > back into an array? Can ActionWebService handle a simple array like > this? The wsdl successfully identifies the parameter as a StringArray.No and Yes... What is most likely occurring is that the request is not properly formatted to match up with the declaration in the WSDL For example, is your Ruby client sending the requests in the same namespace as the server uses? Is it using the SOAP encoding style to send through typed arrays? Are your requests formatted as RPC encoded requests? If you have a look in log/development.log, it would be useful to see what your request XML looks like. Regards Leon
On 8/13/05, leon breedt <bitserf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> If you have a look in log/development.log, it would be useful to see > what your request XML looks like.I''ve committed helper methods to API::Base, so you can easily test this from script/console (you''ll need to be running off Subversion to use this): $ ./script/console>> c = MyApi.soap_client ''http://localhost:3000/myservice/api'' >> c.list_processor ["one", "two", "three"]Regards Leon
On Sat, Aug 13, 2005 at 09:56:02AM +1200, leon breedt wrote:> On 8/13/05, sramsay-zyaWFcxYZ9U@public.gmane.org <sramsay-zyaWFcxYZ9U@public.gmane.org> wrote: > > Do I have to manually coerce the object > > back into an array? Can ActionWebService handle a simple array like > > this? The wsdl successfully identifies the parameter as a StringArray. > No and Yes... > > What is most likely occurring is that the request is not properly > formatted to match up with the declaration in the WSDL > > For example, is your Ruby client sending the requests in the same > namespace as the server uses?Well, I assume so. The request looks like this: WSDL_URL ''http://lachesis.english.uga.edu:8000/dickinson_test/wsdl'' soap = SOAP::WSDLDriverFactory.new(WSDL_URL).createDriver params = [''DEAmsEDCSHDh310.1.xml'', ''DEAmsEDCSHDh367.1.xml'', ''DEAmsEDCSHDhb17.1.xml''] result = soap.HelloWorld(params)> Is it using the SOAP encoding style to > send through typed arrays? Are your requests formatted as RPC encoded > requests?The request XML looks like this: Web Service Request: HelloWorld(param0=>#<SOAP::Mapping::Object:0xb74faab0 @__soap_value_type={"item"=>:multi}, @__soap_value={"item"=>["DEAmsEDCSHDh310.1.xml", "DEAmsEDCSHDh367.1.xml", "DEAmsEDCSHDhb17.1.xml"]}>) Entrypoint: api <?xml version="1.0" encoding="utf-8" ?> <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <env:Body> <n1:HelloWorld xmlns:n1="urn:ActionWebService"> <param0> <item>DEAmsEDCSHDh310.1.xml</item> <item>DEAmsEDCSHDh367.1.xml</item> <item>DEAmsEDCSHDhb17.1.xml</item> </param0> </n1:HelloWorld> </env:Body> </env:Envelope> The main body looks okay to me, but I notice that it''s considering it a SOAP::Mapping::Object on the way in. Is there some way to give a hint in my code to say that the object going in is an array of strings? Thank you so much for the response . . . Steve -- Stephen Ramsay Assistant Professor Department of English University of Georgia email: sramsay-zyaWFcxYZ9U@public.gmane.org web: http://cantor.english.uga.edu/ PGP Public Key ID: 0xA38D7B11
On Sat, Aug 13, 2005 at 09:56:02AM +1200, leon breedt wrote:> On 8/13/05, sramsay-zyaWFcxYZ9U@public.gmane.org <sramsay-zyaWFcxYZ9U@public.gmane.org> wrote: > > Do I have to manually coerce the object > > back into an array? Can ActionWebService handle a simple array like > > this? The wsdl successfully identifies the parameter as a StringArray. > No and Yes... > > What is most likely occurring is that the request is not properly > formatted to match up with the declaration in the WSDLSorry, forgot to mention that I also get this message in the logs: "Casting of method parameters failed" Steve -- Stephen Ramsay Assistant Professor Department of English University of Georgia email: sramsay-zyaWFcxYZ9U@public.gmane.org web: http://cantor.english.uga.edu/ PGP Public Key ID: 0xA38D7B11
On 8/14/05, sramsay-zyaWFcxYZ9U@public.gmane.org <sramsay-zyaWFcxYZ9U@public.gmane.org> wrote:> Web Service Request: > HelloWorld(param0=>#<SOAP::Mapping::Object:0xb74faab0 > @__soap_value_type={"item"=>:multi}, > @__soap_value={"item"=>["DEAmsEDCSHDh310.1.xml", > "DEAmsEDCSHDh367.1.xml", "DEAmsEDCSHDhb17.1.xml"]}>) Entrypoint: api > <?xml version="1.0" encoding="utf-8" ?> > <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > <env:Body> > <n1:HelloWorld xmlns:n1="urn:ActionWebService"> > <param0> > <item>DEAmsEDCSHDh310.1.xml</item> > <item>DEAmsEDCSHDh367.1.xml</item> > <item>DEAmsEDCSHDhb17.1.xml</item> > </param0> > </n1:HelloWorld> > </env:Body> > </env:Envelope>This is interesting. Which version of Ruby are you using (ruby -v)? I suspect your version of SOAP4R has a faulty WSDL driver factory. The param0 element would have looked like this if you were using a Ruby client: <param0 n2:arrayType="xsd:anyType[2]" xmlns:n2="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="n2:Array"> <item xsi:type="xsd:string">DEAmsEDCSHDh310.1.xml</item> <item xsi:type="xsd:string">DEAmsEDCSHDh367.1.xml</item> <item xsi:type="xsd:string">DEAmsEDCSHDhb17.1.xml</item> </param0> Most importantly, notice that your param0 element has no "type" attribute. This attribute must be set to Array (qualified with a SOAP encoding namespace tag) for it to be deserialized into an array. Strictly speaking, arrayType should be "xsd:string[n]" as well, though it doesn''t really matter if its already an array, as AWS will cast the members properly. HTH, Leon
Hi Leon, Are you one of the developers for ActionWebservice? I''ve noticed that your handle shows up a lot on the IRC archives. If so, let me say that (current troubles notwithstanding) this system is pretty amazing. On Sun, Aug 14, 2005 at 11:48:45AM +1200, leon breedt wrote:> On 8/14/05, sramsay-zyaWFcxYZ9U@public.gmane.org <sramsay-zyaWFcxYZ9U@public.gmane.org> wrote: > > Web Service Request: > > HelloWorld(param0=>#<SOAP::Mapping::Object:0xb74faab0 > > @__soap_value_type={"item"=>:multi}, > > @__soap_value={"item"=>["DEAmsEDCSHDh310.1.xml", > > "DEAmsEDCSHDh367.1.xml", "DEAmsEDCSHDhb17.1.xml"]}>) Entrypoint: api > > <?xml version="1.0" encoding="utf-8" ?> > > <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> > > <env:Body> > > <n1:HelloWorld xmlns:n1="urn:ActionWebService"> > > <param0> > > <item>DEAmsEDCSHDh310.1.xml</item> > > <item>DEAmsEDCSHDh367.1.xml</item> > > <item>DEAmsEDCSHDhb17.1.xml</item> > > </param0> > > </n1:HelloWorld> > > </env:Body> > > </env:Envelope> > > This is interesting. Which version of Ruby are you using (ruby -v)? I > suspect your version of SOAP4R has a faulty WSDL driver factory.I''m running ruby 1.8.2. I was under the impression that soap4r had been folded into the main distribution. Would it be worthwhile to download a more recent independent version of it (if there is such a thing)?> Most importantly, notice that your param0 element has no "type" > attribute. This attribute must be set to Array (qualified with a SOAP > encoding namespace tag) for it to be deserialized into an array. > > Strictly speaking, arrayType should be "xsd:string[n]" as well, though > it doesn''t really matter if its already an array, as AWS will cast the > members properly.I''ll try to fiddle around with different versions of things and see if I can get it to work. It sort of felt to me like a bug, but I usually try to assume it''s something I''m doing wrong until I have incontravertable proof otherwise. Thanks for your help. I''ll post to the ng if I figure anything out. Steve -- Stephen Ramsay Assistant Professor Department of English University of Georgia email: sramsay-zyaWFcxYZ9U@public.gmane.org web: http://cantor.english.uga.edu/ PGP Public Key ID: 0xA38D7B11