Home > Uncategorized > Using Webservices with Flex

Using Webservices with Flex

I was working on a larger Flex example this morning: Sending SMS via a webservice in Flex
But due to the Flash sandbox, there is a hurdle you have to jump, security wise, to access a webservice from Flash,
and it first shows it’s ugly head with this exception:

[RPC Fault faultString="Security error accessing url" faultCode="Channel.Security.Error" faultDetail="Unable to load WSDL. If currently online, please verify the URI and/or format of the WSDL (http://www.freebiesms.co.uk/sendSMS.asmx?wsdl)"%5D
    at mx.rpc.wsdl::WSDLLoader/faultHandler()[C:autobuild3.2.0frameworksprojectsrpcsrcmxrpcwsdlWSDLLoader.as:98]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[C:autobuild3.2.0frameworksprojectsrpcsrcmxrpcAbstractInvoker.as:170]
    at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[C:autobuild3.2.0frameworksprojectsrpcsrcmxrpcAbstractInvoker.as:225]
    at mx.rpc::Responder/fault()[C:autobuild3.2.0frameworksprojectsrpcsrcmxrpcResponder.as:53]
    at mx.rpc::AsyncRequest/fault()[C:autobuild3.2.0frameworksprojectsrpcsrcmxrpcAsyncRequest.as:103]
    at DirectHTTPMessageResponder/securityErrorHandler()[C:autobuild3.2.0frameworksprojectsrpcsrcmxmessagingchannelsDirectHTTPChannel.as:389]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/redirectEvent()

Which, after hunting on the Net, showed me that I needed a crossdomain.xml file thus:

<cross-domain-policy>
    <allow-access-from domain="*"/>
    <allow-http-request-headers-from domain="*" headers="SOAPAction"/>
</cross-domain-policy>

– Oh, and I also found out that Webservice method names are case-sensitive, when I got this error:

[RPC Fault faultString="Couldn’t find method ‘sendSms’ in service." faultCode="Client.NoSuchMethod" faultDetail="null"]
    at mx.rpc.soap::Operation/createFaultEvent()[C:autobuild3.2.0frameworksprojectsrpcsrcmxrpcsoapOperation.as:978]
    at mx.rpc.soap::Operation/http://www.adobe.com/2006/flex/mx/internal::invokePendingCall()[C:autobuild3.2.0frameworksprojectsrpcsrcmxrpcsoapOperation.as:763]
    at mx.rpc.soap::Operation/send()[C:autobuild3.2.0frameworksprojectsrpcsrcmxrpcsoapOperation.as:693]
    at Function/http://adobe.com/AS3/2006/builtin::apply()
    at mx.rpc.soap.mxml::Operation/send()[C:autobuild3.2.0frameworksprojectsrpcsrcmxrpcsoapmxmlOperation.as:170]
    at Function/http://adobe.com/AS3/2006/builtin::apply()
    at mx.rpc::AbstractService/http://www.adobe.com/2006/actionscript/flash/proxy::callProperty()[C:autobuild3.2.0frameworksprojectsrpcsrcmxrpcAbstractService.as:290]
    at FreebieSMS/click()[C:Documents and SettingsAdminMy DocumentsVisual Studio 2008ProjectsFreebieSMSFlexFreebieSMSFlexsrcFreebieSMS.as:31]
    at FreebieSMSFlex/___FreebieSMSFlex_Button1_click()[C:Documents and SettingsAdminMy DocumentsVisual Studio 2008ProjectsFreebieSMSFlexFreebieSMSFlexsrcFreebieSMSFlex.mxml:4]

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: