weimingtom / nekonme

Automatically exported from code.google.com/p/nekonme
0 stars 0 forks source link

IOError for webservice request (only flash target works) #217

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Write a class
import nme.net.URLLoader;

import nme.net.URLRequest;
import nme.net.URLRequestMethod;

import nme.net.URLVariables;
import nme.events.Event;
import nme.events.IOErrorEvent;
import nme.net.URLLoaderDataFormat;

import nme.Lib;

class LdTest {
    public function new(){
        var urlRequest = new URLRequest("http://www.openligadb.de/Webservices/Sportsdata.asmx");

        // Below will fail when targeted for HTML5, but succeed for windows,android,flash
        urlRequest.method = URLRequestMethod.POST;
        urlRequest.contentType = "text/xml; charset=utf-8";

        urlRequest.data = '<?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>
    <GetAvailGroups xmlns="http://msiggi.de/Sportsdata/Webservices">
      <leagueShortcut>bl1</leagueShortcut>
      <leagueSaison>2011</leagueSaison>
    </GetAvailGroups>
  </soap:Body>
</soap:Envelope>';

        var urlLoader:URLLoader = new URLLoader();
        urlLoader.dataFormat = URLLoaderDataFormat.TEXT;
        urlLoader.addEventListener(Event.COMPLETE, onComplete);
        urlLoader.addEventListener(IOErrorEvent.IO_ERROR, onNetworkError);

        urlLoader.load(urlRequest);

    }
    public function onComplete(e:Event):Void{
        trace("nomplete");
        trace(e.target.data);
    }
        public function onNetworkError(e:IOErrorEvent):Void{
        trace("error");
        trace(e.target.data);
    //  trace(e.);
    }

}

2. Then use this class in Main
class Main {    

    // constructor
    public function new(){
    }

    // entry point
    public static function main() {
        trace("Hello From FDT haXe NME!");
        var ld:LdTest = new LdTest();
        new Main();

    }
}
2. then try 
nme test config.nmml neko 
nme test config.nmml cpp
nme test config.nmml flash
3.

What is the expected output? What do you see instead?
I expect to find SOAP responce in traces, but find IOError (event.target.data 
null) for cpp and neko targets, flash target is fine.

What version of the product are you using? On what operating system?

haxe 2.08 nme 3.2.0 MacOS 10.7.3 (IDE - FDT5)

haxe 2.08 nme 3.3.0 Windows 7 Pro (german) (IDE - FlashDevelop)

Please provide any additional information below.

I used URLRequestHeader for flash target, but it seems that flash target works 
without URLRequestHeader too (at least for this Webservice that i tested). 
My aim was to write a simple Webservice class for nme.

Original issue reported on code.google.com by elena.ge...@gmail.com on 5 Apr 2012 at 10:27