- Home /
Unity WebPlayer and WWW object
Hello,
I'm working on a project involving Unity WebPlayer and some Soap web services. Here is a part of my code:
string request = CurrentMode.GetInstance().WebServiceUrl+ "/someFunction?";
WWW www = new WWW(request);
Debug.Log("waiting for web service");
while (!www.isDone) ;
Debug.Log("web service done ! ");
if (www.error != null)
{
Debug.Log("Error downloading: " + www.error);
}
else
{
var result = JsonReader.Deserialize<MyClass[]>(www.text);
It's working without a problem in Unity editor and standalone executable. But it doesn't working from Unity WebPlayer.
There is my crossdomain.xml
<?xml version="1.0"?>
<cross-domain-policy>
<allow-access-from domain="*"/>
</cross-domain-policy>
What am I doing wrong ?
Edit: a little precision: The line
Debug.Log("waiting for web service");
Is executed, but
Debug.Log("web service done ! ");
Never. It only occurs when running in WebPlayer.
Edit 2 : This is a log from WebPlayer I stripped unimportant parts (like the load of assemblies)
Input initialized.
desktop: 1920x1200 59Hz; virtual: 1920x1200 at 0,0 Platform assembly: C:\Users\doroshen\AppData\LocalLow\Unity\WebPlayer\mono\3.x.x\Data\lib\System.Core.dll (this message is harmless) Init UnityEngine.Debug:Internal_Log(Int32, String, Object) UnityEngine.Debug:Log(Object) EditorManager:Awake()
(Filename: C:/BuildAgent/work/b0bcff80449a48aa/Runtime/ExportGenerated/WebPlayer/UnityEngineDebug.cpp Line: 43)
Platform assembly: XXXXXXX\AppData\LocalLow\Unity\WebPlayer\player\3.x.x\Data\lib\CrossDomainPolicyParser.dll (this message is harmless)
waiting for web service
The first Debug.log ^^
UnityEngine.Debug:Internal_Log(Int32, String, Object) UnityEngine.Debug:Log(Object) EditorManager:loadAiroports() EditorManager:Awake()
(Filename: C:/BuildAgent/work/b0bcff80449a48aa/Runtime/ExportGenerated/WebPlayer/UnityEngineDebug.cpp Line: 43)
Some features that work in a certain platform, might not work on another. Check this out: http://unity3d.com/support/documentation/ScriptReference/$$anonymous$$onoCompatibility.html
Oh. And even worse then that, from experience, some stuff that are listed as compatible, might not be compatible.
Are you getting any kind of errors, or is it just hanging there?
Answer by jurion · Apr 13, 2012 at 03:56 PM
Ok I'm going to answer my own question, maybe it will helps someone else.
I was trying to simulate a "synchronous" call; because I didn't want my application to do anything before all data is loaded. (It's not a game, but an application for Intranet, so wait time is not really an issue)
It is not possible in WebPlayer. The line
while (!www.isDone) ;
Crushes WebPlayer plugin. Si to use a www class in WebPlayer you must use
StartCoroutine
for asynchronous calls.
$$anonymous$$ark the question as answered please (the "checkbox below the up/down buttons), so that the question won't appear under "Unanswered" tab anymore
$$anonymous$$agnificent! I don't have the rep to upvote you, so I'm giving you a long winded thanks ins$$anonymous$$d. Considering that the plugin can easily have crashed before your latest log message comes to light, this can be VERY misleading as to where the problem is co$$anonymous$$g from. It all needs to move to chained coroutines ins$$anonymous$$d, and then it works fine.
Answer by josodo · Apr 26, 2012 at 05:36 PM
Hi! I'm trying to consume a SOAP web service from unity and i have tried several ideas unsuccessfully. Could you please, bring me some light in this sense? Thanks!