如何实现 Flex 与 Webservice 之间的 XML 通信
Flex 代码<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
function onClick():void{
// 调用Webservice方法
ws.HelloWorld.send();
}
function doneHelloWorld():void{
}
public var datas:XML =<user>
<menuName>burger</menuName>
<price>3.95</price>
</user>
]]>
</mx:Script>
<mx:WebService id="ws" wsdl="http://localhost/InfoManage/webservice/WebService.asmx?wsdl"
showBusyCursor="true" useProxy="false">
<!--要和后台的Webservice方法名相同-->
<mx:operation name="HelloWorld" result="doneHelloWorld">
<mx:request>
<!--要和后台的Webservice方法的参数名相同-->
<username><![CDATA[{datas.toXMLString()}]]></username>
</mx:request>
</mx:operation>
</mx:WebService>
<mx:Button x="347" y="138" label="Button" click="onClick();"/>
<mx:TextInput id="ti" x="299" y="97"/>
<mx:Label id="la" x="362" y="187" text="{ws.HelloWorld.lastResult}"/>
</mx:Application>
Webservice 代码
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Text;
using System.Xml;
/// <summary>
/// WebService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebService : System.Web.Services.WebService {
public WebService () {
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
[WebMethod]
public string HelloWorld(string username) {
XmlDocument doc = new XmlDocument();
return username;
}
}
结果只能显示<user> 我想显示所传递进的XML文档格式的字符串....
如何在Webservice内获取传入信息...请各位帮忙...
--------------------编程问答-------------------- --------------------编程问答-------------------- 问题已经得到解决..请勿回复.... --------------------编程问答-------------------- --------------------编程问答-------------------- UP --------------------编程问答--------------------
补充:.NET技术 , Web Services