开发者

Flex Webservice and Android

开发者 https://www.devze.com 2023-02-25 01:32 出处:网络
I have a problem when I try to access to a webservice from a mobile application. When I try the address of the webservice on my browser, it works, when I try in my application on the emulator of Flash

I have a problem when I try to access to a webservice from a mobile application. When I try the address of the webservice on my browser, it works, when I try in my application on the emulator of Flash Builder, it works. But when I try it on my phone, it doesn't work!

I have access to the web in my application.

I just create the webservice in a view in MXML.

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" 
        title="WebService">
    <fx:Declarations>
        <s:WebService id="webService" wsdl="http://serverweb/Service.asmx?WSDL">
    </s:WebService>
    </fx:Declarations>
</s:View>

I got this exception

[RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Unable to load WSDL. If currently online, please verify the URI and/or format of the WSDL (http://serverweb/Service.asmx?WSDL)"]
at mx.rpc.wsdl::WSDLLoader/faultHandler()[E:\dev\hero_private_beta\frameworks\projects\rpc\src\mx\rpc\wsdl\WSDLLoader.as:103]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at HTTPOperation/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[E:\dev\hero_private_beta\frameworks\projects\rpc\src\mx\rpc\http\HTTPSe开发者_运维百科rvice.as:993]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[E:\dev\hero_private_beta\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:350]
at mx.rpc::Responder/fault()[E:\dev\hero_private_beta\frameworks\projects\rpc\src\mx\rpc\Responder.as:68]
at mx.rpc::AsyncRequest/fault()[E:\dev\hero_private_beta\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:113]
at DirectHTTPMessageResponder/errorHandler()[E:\dev\hero_private_beta\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:410]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()

Can someone help me?

Thank you


I have found and fix my problem. I use a local web server and the phone doesn't translate the hostname into the IP address. So instead of http://serverweb/Service.asmx?WSDL, I put http://192.168.0.5/webservice.asmx?wsdl (where 192.168.0.5 is the ip of serverweb)


You probably forgot to add the internet permission in the manifest. Add this in your app.xml:

<android>
    <manifestAdditions>
    <![CDATA[
    <manifest>
        <uses-permission android:name="android.permission.INTERNET"/>
    </manifest>
    ]]>
    </manifestAdditions>
</android>
0

精彩评论

暂无评论...
验证码 换一张
取 消