Highlighted

Getting exception/error after calling webservice

chandanmahajan

23-09-2008

Hi All,



I am using jboss-4.2.2.GA as the application server. I have
copied flex data service i.e. flex folder contianing its jar file
,configurationf files etc under web-inf folder of my
project.Similary flex related entries are added in web.xml.



I am trying to invoke webservice through following code

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
backgroundColor="#FFFFFF">

<mx:WebService id="srv" wsdl="
http://localhost:8080/tdemandweb/services/ProductThresholdService?wsdl"
showBusyCursor="true" />

<mx:DataGrid dataProvider="{srv.getData.lastResult}"
width="100%" height="100%">

<mx:columns>

<mx:DataGridColumn dataField="name"
headerText="Name"/>

<mx:DataGridColumn dataField="price"
headerText="Price"/>

</mx:columns>

</mx:DataGrid>

<mx:Button label="Get Product Data"
click="srv.getData()"/>

</mx:Application>



After clicking "Get Product Data" button , I am calling
getData method of the webservice. As i have put logger statemetn in
the getData method, I can see that getData method is properly
called. But after returning from the webservice, it is showing me
the following error on the UI,



[RPC Fault faultString="Cannot find type for:
FlexProductData" faultCode="DecodingError" faultDetail="null"]

at mx.rpc.soap::Operation/
http://www.adobe.com/2006/flex/mx/internal::processResult()

at mx.rpc::AbstractInvoker/
http://www.adobe.com/2006/flex/mx/internal::resultHandler()

at mx.rpc::Responder/result()

at mx.rpc::AsyncRequest/acknowledge()

at DirectHTTPMessageResponder/completeHandler()

at flash.events::EventDispatcher/dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

at flash.net::URLLoader/onComplete()





If same code i execute through flex builder 3 , it is
properly invoke the webservice and displays the data. However, if i
call that webservice through flex application which is deployed in
jboss, it is showing above error.



I really new to this technology. I do not understand whether
there is problem of the version which is used in jboss or what ?



Could anybody let me know what would be the problem? how to
solve that problem?



This is urgent requirement and hence early response will be
really appriciated.



Thanks,

Chandan

Replies

Highlighted

chandanmahajan

29-09-2008

Hi riesvantwisk ,

Thanks for your response,

Please see my mxml file below,



<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
initialize="Handler()">

<mx:Script>

<![CDATA[

import mx.controls.Alert;

import mx.rpc.soap.WebService;

import mx.binding.utils.BindingUtils;

import mx.collections.ArrayCollection;

[Bindable]

private var _stateService:WebService;

private function Handler():void{

_stateService = new WebService();

_stateService.wsdl="
http://localhost:8080/tdemandweb/services/ProductThresholdService?wsdl"

_stateService.loadWSDL();

_stateService.getData.send();

}

]]>

</mx:Script>



<mx:DataGrid id="Urdg"
dataProvider="{_stateService.getData.lastResult.results}"
width="100%" height="100%">

<mx:columns>

<mx:DataGridColumn dataField="name"
headerText="Name"/>

<mx:DataGridColumn dataField="price"
headerText="Price"/>

<mx:DataGridColumn dataField="productId"
headerText="Product Id"/>

<mx:DataGridColumn dataField="description"
headerText="Description"/>

<mx:DataGridColumn dataField="category"
headerText="Category"/>

</mx:columns>

</mx:DataGrid>



</mx:Application>





After calling getData method, webservice is returning me an
object of the Resultlist class(user defined class) which contain a
field results of type Arraylist. This arraylist object contains the
object of FlexProductData.java



Please see Flexproductdata.java below

package com.tdemand.common.service.common.types;



import java.io.Serializable;



public class FlexProductData implements Serializable {

private int productId;



private String name;



private String description;





private String category;



private double price;



// and setter and getter method of above field

}





In this way, webservice returning me the an object (named
results) of ResultList Class which contains the Arraylist object
results. This arraylist object i.e. results contains
Flexproductdata objects.



Now could you please let me know in what way the similar
class i should create on the flex side? and where to put in
project.

I have deployed my project on jboss.



Please let me know resposne ASAP possible as this is
extermely urgent requirement in our project?



One this, if i run above mxml through flex builder which uses
sdk3.1.0 for compilation , it works fine. But if the similar file I
deploy on jboss it is throwing me the above exception. I have
included LCDS in my jboss. All other flex program are running fine
in the jboss. Only this issue is causing me the problem.



Let me know if you need more information on this.



Thanks,



Regards,

Chandan













Highlighted

chandanmahajan

29-09-2008

Just for your reference Please see getData method of my
webservice,



public ResultList getData() throws AuthorizationException,
StartIndexOutOfBoundsException {

logger.debug("***************started getData method of
productthresholdspojoserviceimpl");

ResultList result = new ResultList();

List list = new ArrayList();

for(int i=0;i<21;i++)

{

FlexProductData fproddata= new FlexProductData();

fproddata.setProductId(10+i);

fproddata.setName("kitkat:"+i);

fproddata.setPrice(10.25+i);

fproddata.setDescription("nice chocalate:"+i);

fproddata.setCategory("category"+i);

list.add(fproddata);



}

result.setResults(list);

return result;

}