PDA

View Full Version : Struggling with Flex2 WebService client


ryan_m
08-02-2006, 07:44 PM
Folks,

I am struggling here, hopefully somebody can get me going in the right direction. I'm an experienced AS2 developer who's recently learnt AS3 and Flex. I'm trying to create a flex2 app that acts as a client to a web service. I've found that very simple scenarios work, for example: If I use the WebService object (either through MXML or the AS3) I can point it to my WSDL file and then make a call to a webservice operation that doesn't accept any parameters and returns a simple string. So I know the basic connectivity is working. But I am struggling when working with operations that requires parameters. I've tried to pass the parameters via the mx:request object and also in code and I generally get the following error:

faultCode:Server.Error.Request
faultString:'HTTP request error'
faultDetail:'Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://devzonedemo.businessobjects.com:8080/dswsbobje/services/session"]. URL: http://devzonedemo.businessobjects.com:8080/dswsbobje/services/session'

So I have two specific questions:

1) When the WSDL for a web service operation defines an argument that is a complexType, what is the syntax for passing these parameters either through raw AS3 code or via the MXML WebService component?

2) I've read in the livedocs that anytime the Flash player makes an HTTP request (like when it calls a web service) and the status code is anything other than 200 (OK) then the Flash Player doesn't get the content of the response and thus can't provide proper handling of soap faults. It says to use a proxy (i.e. the useProxy="true" property) but I dont really know what this means or how to use it. If I just keep my code the same and set useProxy to true then I get this:

faultCode:InvokeFailed
faultString:'[MessagingError message='Unknown destination 'DefaultHTTP'.']'
faultDetail:'Unable to load WSDL. If currently online, please verify the URI and/or format of the WSDL (../session.wsdl)'

So how do I get Flash to properly give me soap faults back? As you can see, this is closely related to my first question because if I got a good error message back I'd most likely know what I'm doign wrong with the parameters.

Any help or ideas would be much appreciated. Thank you in advance..

Ryan

tg
08-02-2006, 08:08 PM
well not 100% sure about this (im in the same boat you are learning this stuff), but here is how i think you can do it.

<mx:WebService
id="projectObject"
useProxy="false"
wsdl="http://myserver/mysite/cfcs/project.cfc?wsdl">

<mx:operation name="addProject" result="handleProjAdd_Result(event)" fault="handleProj_Fault(event)">
<mx:request>
<pName>{projName.text}</pName>
</mx:request>
</mx:operation>
</mx:WebService>

so.... the webservice operation is the method you are calling for your webservice.
and mx:request is the parameter you are sending to that method.

now whether you can put multiple nodes in 1 request node for multiple arguments, or if you need a seperate request for each... i dont know that either.

i really dont know much about this.... still playing with it. so if this works out for you, i would appreciate any kind of feedback / info that you learn.
thanks.

ryan_m
08-02-2006, 08:17 PM
Yeah I've tried very similar code (just did it again from scratch to make sure) and this is where I get the HTTP request error. What I think is happening is that the parameters aren't in the right format so a soap fault is occuring but because the return status code is 500 (server error) then flash doesn't get to see the response so I don't get a proper error. I get an error as if the web service URL was down or something. Therin lies my cyclical problem :(

pfratus
12-11-2006, 03:05 PM
Did you ever find a solution to the Flex vs Web Service problem. I think I have proven that it's the Web Service and not Flex trying to call it.
Pete

heavenly_ray
12-31-2006, 11:25 AM
my flex .swf works fine if I set the wsdl to localhost. But when I point to production URL if comes back with

"Error #2032 Stream Error"

What could be the problem if everything works fine in my local machine and does not work on the remote/production machine? I added crossdomain.xml to the root.

Please let me know if you find a solution. I am desparately waiting for an answer.

k4shah
02-07-2008, 04:50 PM
Guys any solution for the HTTP REquest Error for WEbservice call from FLEX....for us we are able to load 5 webservice calls and left with 2 which continusly throws the error when we load the page....also Once the page load if we click Browser Refresh- Webservice error starts...

let us know if any one has solution for same...

pavanv007
08-22-2008, 07:31 PM
Hi,
Any one found solution to this problem. I am also getting "HTTP Requesr Error" , when i tried to invoke a webservice and tried to pass the parameters via the mx:request object .

Fault Detail is as foloows.
"Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://localhost:8080/mmdbServices/services/MinManagementDBService"]. URL: http://localhost:8080/mmdbServices/services/MinManagementDBService"

When the WSDL for a web service operation defines an argument that is a complexType, what is the syntax for passing these parameters either through raw AS3 code or via the MXML in mx:request tag?

ryan_m.. How did you solve this problem?

chandra2034
05-27-2009, 11:26 PM
Hi,

I solved Complex Object Error in Flex 3 webservice call. here is one example.
Solution is in <mx:Request>{bindable parameter}</mx:request>


Example:

[Bindable]
public var profileObject:StorageProfile =new StorageProfile();
private function addLSTP():void
{

var lsTPGoal:Exam=new Exam();
var goalConstraint:Constraint=new Constraint();
goalConstraint.Passed = true;
goalConstraint.Rank = 2;
goalConstraint.Requirement =true;
var arrCons:ArrayOfConstraint=new ArrayOfConstraint();
arrCons.addConstraint(goalConstraint);
lsTPGoal.Constraints = arrCons;
var arrGoal:ArrayOfGoal =new ArrayOfGoal();
arrGoal.addGoal(lsTPGoal);
profileObject.Goals=arrGoal;
Security.allowInsecureDomain("*");
ws1.CreateProfile();
}

<mx:Button id="btnProf" label="Add LStP" click="addLSTP()">
<mx:WebService id="ws1" makeObjectsBindable="true" useProxy="false" wsdl="http://localhost:8000/myService?wsdl">
<mx:operation name="CreateProfile">
<mx:request>
{profileObject}
</mx:request>
</mx:operation>
</mx:WebService>