user1255894
user1255894

Reputation: 35

Flex adds incorrect port to CFC call

I have a Flex/CF app that sits on 2 redundant servers behind a load balancer. Both the Flex and CF side make calls to the same CFC. The Flex, CF and CFC are all in the same folder. When the CF code calls the CFC, there's not a problem. However, when the Flex code calls the CFC, it adds an explicit port "84" to the URL. This causes a problem for the load balancer which only accepts traffic from port 80. As I understand it, the load balancer would internally route requests from port 80 to 1 of the 2 servers on port 84 (but that internal routing should be invisible to the client).

I've hardcoded the WSDL location in the flex code like this:

services.xxxService.wsdl = "http://devsite.xxx.com/xxx/xx/xx/xx.cfc?wsdl";

I've also tried a relative path when defining the WSDL location like this:

services.xxxService.wsdl = "xx/xx/xx.cfc?wsdl";

Both result in the webservice call looking like (when I look in the Charles packet sniffer):

http://devsite.xxx.com:84/xxx/xx/xx/xx.cfc?wsdl

I've created multiple Flex apps with this similar setup and never had this issue. I even deployed this app to several servers WITHOUT a load balancer and I don't see a port specified in any of the Flex to CFC calls.

What about Flex causes it to call the WSDL with a port number and the CF code does not? Is something happening on the load balancer that I'm not aware?

Upvotes: 2

Views: 364

Answers (1)

Shawn Holmes
Shawn Holmes

Reputation: 3762

This isn't a Flex problem, it's a ColdFusion problem. By default, WSDLs created off of a CFC (with no additional parameters specified) generate a <wsdlsoap:address location> element derived by introspection. That is, the CF server looks at its own local instance information, and produces an absolute URL that matches its settings...

...this includes a non-standard port, which will manifest in your situation--when the ColdFusion server sits behind a load-balancer that redirects traffic from 80 to another port.

Solution: In CF8 or higher, you may add a new attribute to the tag, "serviceaddress":

<cfcomponent output="false" serviceaddress="http://127.0.0.1:80/myService.cfc">

This will force the CFC to produce the correct <wsdlsoap:address location> element when a WSDL is requested.

The reason why your CF client works correctly, but Flex client does not...is that the CF client does not honor the WSDL's address location in the XML, but instead, uses the initial address it is instantiated with for its stub.

Upvotes: 2

Related Questions