- Home /
Parallel web service request using WWW in Webplayer
Is there any way to use WWW to make multiple parallel request to a web service? My experience so far is that even if I instantiate multiple instances of the WWW class, unity appears to be serializing the calls.
I know the web service is able to handle simultaneous requests to the web service from a single client since I have tested this to be working with a simple console application.
I also know that my request is properly formed because I can do receive my data albeit not with the concurrency that I am expecting.
Here is some test code that I have written for my test. Do you see any error in there that would prevent me from getting concurrent requests to my web service?
Thanks for your inputs.
public class Test : MonoBehaviour {
void Start () {
for (int i = 0; i < 100; ++i)
{
var wGO = new GameObject("WWW Downloader");
wGO.AddComponent<WWWWaiter>();
}
} }
public class WWWWaiter : MonoBehaviour {
IEnumerator Start() { string wQuery = "it.Id is not null";
var wUrl = String.Format("https://{0}/Services/NodeService.svc", "127.0.0.1");
var wHeaders = new Hashtable();
wHeaders["Content-Type"] = "text/xml; charset=utf-8";
wHeaders["SOAPAction"] = "http://tempuri.org/INodeService/Query";
wHeaders["Expect"] = "100-continue";
var wQueryXml = String.Format(
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body>" +
"<Query xmlns=\"http://tempuri.org/\"><iQuery>{0}</iQuery></Query>" +
"</s:Body></s:Envelope>",
wQuery);
UTF8Encoding wEncoder = new UTF8Encoding();
var wData = wEncoder.GetBytes(wQueryXml);
var wWWW = new WWW(wUrl, wData, wHeaders);
wWWW.threadPriority = UnityEngine.ThreadPriority.High;
yield return wWWW;
Debug.LogError("One Completed");
} }