{"id":208,"date":"2009-07-09T23:25:12","date_gmt":"2009-07-09T22:25:12","guid":{"rendered":"http:\/\/blog.pczone.be\/?p=208"},"modified":"2009-07-09T23:25:12","modified_gmt":"2009-07-09T22:25:12","slug":"grails-xfire-flex-flex-xfire-error-2032-streamfout","status":"publish","type":"post","link":"https:\/\/blog.pczone.be\/?p=208","title":{"rendered":"Grails XFire + Flex (flex xfire Error #2032: Streamfout.)"},"content":{"rendered":"<p>I&#8217;m building a small application for myself. It will manage my orders and invoices. Reason I&#8217;m doing this is mainly to try out new stuff. I thought I&#8217;ld try out a Grails soap backend with a Flex frontend. Doesn&#8217;t sound to difficult, right? Well I ran into a problem and it took me some time before I found a solution.<\/p>\n<p>I had created a simple webservice that would return all my orders. Something like this piece of code<\/p>\n<blockquote><p>class PurchaseOrderWebService {<\/p>\n<p>boolean transactional = true<br \/>\nstatic expose=[&#8216;xfire&#8217;]<\/p>\n<p>PurchaseOrder findById(Long id){<br \/>\nreturn PurchaseOrder.get(id)<br \/>\n}<\/p>\n<p>PurchaseOrder[] findAll(){<br \/>\nprintln(&#8216;listing all&#8217;)<br \/>\nreturn PurchaseOrder.list() as PurchaseOrder[]<br \/>\n}<\/p>\n<p>PurchaseOrder save(PurchaseOrder order){<br \/>\nreturn order.save()<br \/>\n}<br \/>\n}<\/p><\/blockquote>\n<p>Pretty simple don&#8217;t ya think. This is now accessable as a soap webservice. In Flex I used the generator to generate all my stubs. The Flex code would look something like this<\/p>\n<blockquote><p>public function loadData():void<br \/>\n{<br \/>\nAlert.show(&#8220;test5&#8221;);<br \/>\nvar service:generated.webservices.PurchaseOrderWeb = new generated.webservices.PurchaseOrderWeb();<br \/>\nservice.addEventListener(FaultEvent.FAULT,errorHandler);<br \/>\nservice.addfindAllEventListener(findAllListener);<br \/>\nservice.findAll();<br \/>\n}<\/p>\n<p>public function findAllListener(e:generated.webservices.FindAllResultEvent):void<br \/>\n{<br \/>\nthis.orderDG.dataProvider = e.result;<br \/>\n}<\/p><\/blockquote>\n<p>Here I show the alert so I&#8217;m sure I&#8217;m not using a cached version of the SWF. However doing this returns a Error #2032. Why? Well I don&#8217;t know. I tried using the soap service from another programming language (c#) and it worked fine. After much googling I finally found the answer. For some reason Flex doesn&#8217;t like it when you don&#8217;t supply an argument to the soap call. The piece of code that finally did the trick looks like this<\/p>\n<p>Grails<\/p>\n<blockquote><p>class PurchaseOrderWebService {<\/p>\n<p>boolean transactional = true<br \/>\nstatic expose=[&#8216;xfire&#8217;]<\/p>\n<p>PurchaseOrder findById(Long id){<br \/>\nreturn PurchaseOrder.get(id)<br \/>\n}<\/p>\n<p>PurchaseOrder[] findAll(String dummy){<br \/>\nprintln(&#8216;listing all&#8217;)<br \/>\nreturn PurchaseOrder.list() as PurchaseOrder[]<br \/>\n}<\/p>\n<p>PurchaseOrder save(PurchaseOrder order){<br \/>\nreturn order.save()<br \/>\n}<\/p>\n<p>}<\/p><\/blockquote>\n<p>Flex<\/p>\n<blockquote><p>public function loadData():void<br \/>\n{<br \/>\nAlert.show(&#8220;test6&#8221;);<br \/>\nvar service:generated.webservices.PurchaseOrderWeb = new generated.webservices.PurchaseOrderWeb();<br \/>\nservice.addEventListener(FaultEvent.FAULT,errorHandler);<br \/>\nservice.addfindAllEventListener(findAllListener);<br \/>\nservice.findAll(&#8220;test&#8221;);<br \/>\n}<\/p>\n<p>public function findAllListener(e:generated.webservices.FindAllResultEvent):void<br \/>\n{<br \/>\nthis.orderDG.dataProvider = e.result;<br \/>\n}<\/p><\/blockquote>\n<p>Strange bug if you ask me. I hope this get&#8217;s indexed and it will help other people facing this problem.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m building a small application for myself. It will manage my orders and invoices. Reason I&#8217;m doing this is mainly to try out new stuff. I thought I&#8217;ld try out a Grails soap backend with a Flex frontend. Doesn&#8217;t sound to difficult, right? Well I ran into a problem and it took me some time &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.pczone.be\/?p=208\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Grails XFire + Flex (flex xfire Error #2032: Streamfout.)&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[4],"tags":[],"class_list":["post-208","post","type-post","status-publish","format-standard","hentry","category-informatics"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p3U9nk-3m","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/blog.pczone.be\/index.php?rest_route=\/wp\/v2\/posts\/208","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.pczone.be\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.pczone.be\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.pczone.be\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.pczone.be\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=208"}],"version-history":[{"count":1,"href":"https:\/\/blog.pczone.be\/index.php?rest_route=\/wp\/v2\/posts\/208\/revisions"}],"predecessor-version":[{"id":209,"href":"https:\/\/blog.pczone.be\/index.php?rest_route=\/wp\/v2\/posts\/208\/revisions\/209"}],"wp:attachment":[{"href":"https:\/\/blog.pczone.be\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.pczone.be\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=208"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.pczone.be\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}