I’m not sure the differences a web app has from the unity editor, but I have a working HTTP POST request working in my unity editor pulling information from a web service. However, when I build it to a web app, the app no longer connects to the web service. I’m getting the error:
(Filename: /Users/build/builds/unity-26/unity-2.6.x/Projects/…/Runtime/Export/Generated/BaseClass.cpp Line: 1783)
You are trying to load data from a www stream which had the following error when downloading.
Failed downloading ws.historicaloptiondata.com
UnityEngine.WWW:get_data()
UnityEngine.WWW:get_data()
$:MoveNext()
Is there something I will need to add to my POST request to allow the web app to to access their server, or some sort of security issue when trying to access a web service via browser that I have to adjust?
In the editor we use Mono’s networking libraries whereas in the browser we hand-off all network operations to the browser itself (so we get the benefit of browser file caching). Can you share your code? That might help us sort this one out.
I assumed it was some sort of caching issue from what I’ve read about streaming issues, but I couldn’t find a solution or a way around it. This is the code for the actual request to the web service:
static function GetPartialOptions (symbol: String, month : String, userToken : String) // Partial options call
{
var maxRowsToReturn = "30";
var encoding = new System.Text.UTF8Encoding();
var postHeader = new Hashtable();
var xmlPostData = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
"<soap:Body>" +
"<GetPartialOptionChain xmlns=\"http://ws.historicaloptiondata.com/\">" +
"<userToken>" + userToken + "</userToken>" +
"<symbol>" + symbol + "</symbol>" +
"<quotedate>" + dateTimeString + "</quotedate>" +
"<StrikeTypes>" + "3" + "</StrikeTypes>" +
"<OptionTypes>" + "0" + "</OptionTypes>" +
"<ExpirationTypes>" + "0" + "</ExpirationTypes>" +
"<bIncludeGreeks>" + "false" + "</bIncludeGreeks>" +
"<OnlyCountCredits>" + "false" + "</OnlyCountCredits>" +
"<maxRowsToReturn>" + maxRowsToReturn + "</maxRowsToReturn>" +
"<asXML>" + "false" + "</asXML>" +
"<IncludeHeaderOrSchema>" + "true" + "</IncludeHeaderOrSchema>" +
"<exactMonthYYYYMM>" + month + "</exactMonthYYYYMM>" +
"</GetPartialOptionChain>" +
"</soap:Body>" +
"</soap:Envelope>";
postHeader.Add("Content-Type", "text/xml");
postHeader.Add("Content-Length", xmlPostData.Length);
postHeader.Add("SOAPAction", "http://" + HOSTADDRESS + "/GetPartialOptionChain");
return new WWW(HOSTADDRESS, encoding.GetBytes(xmlPostData), postHeader);
}
This returns to me a comma separated value string of data that I pull with:
var optionChainData1 = dataPull.GetPartialOptions(textEnter.stockSymbol, specialMonthFormat[0], tokenNumber);
yield optionChainData1;
I have a few different requests that get sent out for the program (one that logs me into my account and gets a token to get info, and then I request 5 sets of data like this one before moving on to the next part of the program). Hope this helps Higgy, let me know if you need anything else to go on.
I’ve looked into stream errors and haven’t found anything useful. The web service company isn’t having issues on their end, and assured me that sending the request from a website app should work. So I am still at a loss why it’s failing download immediately after request. I’ve tried it on a few browsers all with the same error.
so i’ve tried opening my application in different browsers, and on different computers. i’ve tried clearing cache beforehand, and it still does not pull like it’s supposed to while in the web app build. I’m at a lose for things to try to get it to work, and if it doesn’t work inside the unity web app, I’ve just wasted a lot of time developing an app that only works inside the unity editor. any help from anyone would be useful about this matter
would be very strange if it wouldn’t work within the browser, normally chances are higher that it does not work outside of it due to forgotten cookies / sessions that your browser has but not the standalone / editor.
I’ve just recently developed something similar though not with SOAP requests and it worked on both ends for me.
I’ve unhappily 0 experience with SOAP but from general web requests: is the full url required for the soap action block? (I ask because the normal requests commonly are explicitely without the protocol), are you sure that the headers you get from being in the browser doesn’t fight your setup here and that you don’t kill your own stuff by adding headers already present in the request?
I tried taking out the headers I’m putting in, but it just didn’t send or gather any information at all. Not sure exactly what you were suggesting, or at least how to fix my script with what you suggested. I did notice that the error states it failed downloading from “ws.historicaloptiondata.com”, when the info might need to come from a more specific site.
not sure if the error sends back the generic website or if this is where the error comes into play, i.e. ws.historicaloptiondata.com doesn’t have the data so it cannot download, and therefore the error. if maybe there is something I am supposed to do or change to access the subsite that has the data, maybe that’s the issue. I’m still fairly new to these types of requests, and i used an example script when i wrote my code so I may have unneeded code somewhere in there that works in the editor but fouls up when it reaches the browser version.
if you want to point out which lines you think may be messing it up, dream, i’ll try it out again.