views:

5068

answers:

6

Hi Guys,

Im using Flex 3 and the WebService component. I started getting the following fault

 HTTP request error

when making a call to service method. This error only showed up and i cant figure out whats causing it

 <mx:WebService
    useProxy="false"
    id= "myService">
         <mx:operation name="getName" resultFormat="object"
     result="getNameResultHandler(event)"
     fault="faultHandler(event)"/>
 </mx:WebService>

i set the wsdl im my init method which i read in as a flashvar. ANy ideas?

the code i use to make the call goes as follows;

var id:Strig = Application.application.parameters.id;
mysERVICE.getname(id);
+2  A: 

Add the following to faultHandler():

trace(event.fault.faultString, "Error");
if (event.fault is SOAPFault) {
    var fault:SOAPFault=event.fault as SOAPFault;
    var faultElement:XML=fault.element;
    // ...
}

That'll give you something to start picking.

dirkgently
i already log this and get the Http Request error
combi001
Try accessing the webservice via your browser/libcurl.
dirkgently
A: 

i already log this and get "Http Request error"

combi001
+1  A: 

Use a http debugger like Fiddler to find out what the exact request/response is. Flex doesn't expose the details of soap errors, or at least it didn't use to. See here, for example.

Paul-Jan
A: 

ok im seeing the following when the error is thrown

[RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://localhost:9081/app/services/RoomLookup"]. URL: http://localhost:9081/`app/services/RoomLookup`"]

the url it shows is different to teh wsdlUrl i supply as a parameter which is

app/services/RoomLookup

is flex appending the localhost or could this be something stored in cache

combi001
Where is the service hosted? You need to add a host and port number to the service end-point. 'app/services/RoomLookup' is not enough.
dirkgently
is on my local machine, im using RAD
combi001
also this wsdlUrl works for other webservice calls on the same server, its just one method causing the problem
combi001
i can see an error 500 when i follow the call - i dont get why it works from some calls and not for others though!
combi001
+2  A: 

Most SOAP and RPC frameworks will set the HTTP status code of an error response to 500. The Flash Player is not able to process the contents of an HTTP response whose status code is 500, so it can be difficult to work with. Unfortunately, there is no way to work around this problem in the player, so the most common approach seems to be to ensure that the server doesn't set the HTTP status of error responses to 500 for requests whose user agent is a Flash Player.

erikprice
I'll second Erik's answer here. We wrote a filter (we're using Tomcat) that changes all 500s to 200s and that allows you on the Flex side to access the wealth of information returned from a SOAP fault.
Rob S.
A: 

what if its not a soap fault? how do you catch that?

Tunde