Suttit nu o slitigt mitt hår. Fick ihop en simpel webservice i .net. Lyckas ladda en xml fil fast fattar inte hur jag skickar tillbaka o sparar den, får fel i flashen.
Service1.asmx
<%@ WebService Language="C#" class="MyClass" %>
using System;
using System.IO;
using System.Xml;
using System.Web.Services;
using System.Data;
[WebService(Namespace="http://localhost/webservices/")]
public class MyClass
{
[WebMethod()]
public XmlDocument loadXML(string fullpath)
{
XmlDocument doc = new XmlDocument();
doc.PreserveWhitespace = true;
doc.Load(fullpath);
return doc;
}
[WebMethod()]
public void saveXML(string fullpath, XmlDocument myXml)
{
XmlDocument doc = new XmlDocument();
doc.PreserveWhitespace = false;
doc = myXml;
doc.Save(fullpath);
}
}
Flashen
import mx.services.*
var wsdl:String = "http://localhost/flash_service/Service1.asmx?WSDL"
var WebServiceConn:WebService
WebServiceConn = new WebService(wsdl);
WebServiceConn.onFault = function(result):Void
{
trace(result.faultcode)
if (result.faultcode == "Client.Disconnected")
{
trace("ej uppkopplad")
}
};
var xmldefaultLoad:String = "http://localhost/flash_service/test.xml";
var xmldefaultSave:String = "http://localhost/flash_service/test_new.xml";
var myXML = new XML("<root><test>Tjoho</test></root>");
btnLoad.onRelease=function()
{
var webcall:PendingCall = WebServiceConn.loadXML(xmldefaultLoad);
webcall.onResult = function(result)
{
trace("WEBSERVICE LOAD: "+result.XML)
//_root.play();
};
webcall.onFault = function(fault)
{
trace("WebService fel. "+ fault.faultcode)
};
}
btnSave.onRelease=function()
{
var webcall:PendingCall = WebServiceConn.saveXML(xmldefaultSave, myXML);
webcall.onResult = function(result)
{
trace("Saved XML")
};
webcall.onFault = function(fault)
{
trace("WebService fel. "+ fault.faultcode)
};
}