Flex Webservice and Android

爷,独闯天下 提交于 2020-01-07 04:35:17

问题


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\HTTPService.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


回答1:


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)




回答2:


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>


来源:https://stackoverflow.com/questions/5665782/flex-webservice-and-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!