gpt4 book ai didi

web-services - 来自 Flex 的 SOAP 请求问题

转载 作者:行者123 更新时间:2023-12-04 16:58:07 26 4
gpt4 key购买 nike

总和:我最终不得不手动形成 XML。我还必须创建一个操作并使用它的 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>

来自银光:
<d4p1:Value xmlns:d6p1="http://www.w3.org/2001/XMLSchema" i:type="d6p1:string">DMS</d4p1:Value>

如果我接受 Flex 生成的请求,用 Fiddler 捕获它,修改那一行以包含“type”命名空间——它可以工作。

任何人都知道如何将该命名空间添加到从 Actionscript 传递给 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);

谢谢,
乔希

最佳答案

使用的默认 SOAPEncoder 的功能有限(例如不包括您上面提到的 type 属性)。幸运的是,有一种方法可以通过编写自己的编码器来控制它。

请参阅 adobe 上的此链接(阅读有关使用自定义 Web 服务序列化的部分)Link on Adobe's Site

关于web-services - 来自 Flex 的 SOAP 请求问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13587176/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com