SUM:我最终不得不手动构建XML。我还必须创建一个Operation并使用它的send();方法,而不仅仅是像WebService.MyServiceFunction(); - 不确定为什么会这样。
我按如下方式发送请求:
var xm:XML =
<SetPropertiesForCurrentUser xmlns="http://asp.net/ApplicationServices/v200">
<values xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<d4p1:KeyValueOfstringanyType>
<d4p1:Key>{obj.Key}</d4p1:Key>
<d4p1:Value xmlns:d6p1="http://www.w3.org/2001/XMLSchema" i:type="d6p1:string">{obj.Value}</d4p1:Value>
</d4p1:KeyValueOfstringanyType>
</values>
</SetPropertiesForCurrentUser>;
var profileService:WebService = new WebService();
profileService.useProxy = false;
profileService.loadWSDL(url);
var o:Operation = profileService.SetPropertiesForCurrentUser;
o.send(xm);
这是我的情景:
我有ASP.NET Web服务来处理身份验证,用户角色和用户配置文件(确切地说是默认的ASP.NET AuthenticationService,RoleService和ProfileService)。
因此,从我的Flex Web应用程序,我能够成功调用ASP.NET服务。例如,像这样的东西工作正常:
var profileService:WebService = new WebService();
profileService.useProxy = false;
profileService.GetAllPropertiesForCurrentUser.addEventListener("result",getAllPropertiesForCurrentUser_EventHandler);
profileService.addEventListener("fault",getAllPropertiesForCurrentUserFault_EventHandler);
profileService.loadWSDL(url);
profileService.GetAllPropertiesForCurrentUser();
当我需要将Dictionary对象传递给服务上的另一个函数(SetPropertiesForCurrentUser)时,我遇到了麻烦。 .NET服务要求这种类型的值:
System.Collections.Generic.IDictionary(Of String,Object)
以下是来自我的ASP.NET服务的web.config条目中的两个相关条目:
<properties>
<clear/>
<add name="coordinateFormat" />
</properties>
...
<profileService enabled="true"
readAccessProperties="coordinateFormat"
writeAccessProperties="coordinateFormat"/>
因此,在从Silverlight应用程序(按预期工作)汇总SOAP请求后,我将其缩小到发送给SOAP处理程序的XML请求的差异:
来自Flex:
<tns:Value>DMS</tns:Value>
来自Silverlight:
<d4p1:Value xmlns:d6p1="http://www.w3.org/2001/XMLSchema" i:type="d6p1:string">DMS</d4p1:Value>
如果我接受Flex生成的请求,请用Fiddler捕获它,修改那一行以包含“type”命名空间 - 它可以工作。
任何人都知道我如何将这个命名空间放到我从Actioncript传递给SOAP处理程序的变量上?这是我发送SetPropertiesForCurrentUser函数的代码:
var obj:Object = {};
obj["Key"] = "coordinateFormat";
obj["Value"] = DMS;
var profileService:WebService = new WebService();
profileService.useProxy = false;
profileService.SetPropertiesForCurrentUser.addEventListener("result",setPropertiesForCurrentUser_EventHandler);
profileService.addEventListener("fault",setPropertiesForCurrentUserFault_EventHandler);
profileService.loadWSDL(url);
profileService.SetPropertiesForCurrentUser(new ArrayCollection([obj]),false);
谢谢, 约什
答案 0 :(得分:0)
使用的默认SOAPEncoder是一些限制其功能的东西(比如不包括上面提到的type属性)。幸运的是,有一种方法可以通过编写自己的编码器来控制它。
在adobe上查看此链接(阅读有关使用自定义Web服务序列化的部分)Link on Adobe's Site