Adobe AIR 和网络服务调用。错误#1085:元素类型“br”必须以匹配的结束标记“
”结束。
这是我的简单代码,如果从 php 或 adobe air 之外的任何其他客户端调用,该代码可以正常工作。相同的代码也可以通过从 SWF 调用来工作,项目的其他部分也有 florineFX 代码,但它不会做任何事情来打破这个问题。
我确实发现一件事,所有 POST 调用都以某种方式更改为 GET,这真的让我感到惊讶。我很高兴得到这个问题的答案。预先感谢大家。下面是我的网络服务中几乎相同的代码。其下方有 AIR 代码。
[WebMethod(EnableSession = true)]
public bool Authenticate(string UserName,string Password)
{
try
{
if (Membership.ValidateUser(UserName, Password)){
FormsAuthentication.SetAuthCookie(UserName, true);
return true;
}
return false;
}
catch (Exception ex)
{
return false;
}
}
我从 adobe AIR 进行的调用代码如下
var ws:WebService = new WebService();
ws.wsdl="http://mysite.com/myservice.asmx?WSDL";
ws.useProxy=false;
ws.addEventListener(LoadEvent.LOAD,onWSDLLoad);
ws.loadWSDL();
ws.Authenticate.addEventListener(ResultEvent.RESULT,resultHandler);
ws.Authenticate.addEventListener(FaultEvent.FAULT,onLoginFaultHandler);
ws.Authenticate("usrname","password");
protected function onLoginFaultHandler(event:FaultEvent):void
{
Alert.show('Login Failed with messsage\r\n[ '+event.fault.faultString+' ]');
/* Error #1085: The element type "br" must be terminated
by the matching end-tag "</br>". */
/* checking the content value of fault event shows
same out put as http://mysite.com/myservice.asmx */
}
protected function onLoginResultHandler(event:ResultEvent):void
{
/* on success code */
}
此人在页面 http://verveguy.blogspot.com/2008/07/truth-about-flex-httpservice.html
- 所有 HTTP GET 请求都会去除标头。它不在 Flex 堆栈中,因此它可能是底层 Flash 播放器运行时。
- 所有具有除“application/x-www-form-url-encoded”之外的内容类型的 HTTP GET 请求都将转换为 POST 请求
- 所有没有实际发布数据的 HTTP POST 请求将转换为 GET 请求。请参阅 1/ 和 2/
- 所有 HTTP PUT 和 HTTP DELETE 请求都将转换为 POST 请求。这似乎是 Flash 播放器所受的浏览器限制。
我确实看到上面的请求变成了 GET,但随后我确实在其中包含了发布值。或者如果这些内容没有被 Web 服务对象发送或记录?
Here is my simple code, which works fine if called from php or any other client then adobe air. Same code also works from calling from SWF, there is fluorineFX code for other part of project as well, but then it doesn't do anything to break this.
I do find one thing that all POST calls were somehow changing to GET, which really amazes me. I would be so glad to get the answer for this. Thanks in Advance everyone. Below is the almost same code from my web service. with AIR code just under it.
[WebMethod(EnableSession = true)]
public bool Authenticate(string UserName,string Password)
{
try
{
if (Membership.ValidateUser(UserName, Password)){
FormsAuthentication.SetAuthCookie(UserName, true);
return true;
}
return false;
}
catch (Exception ex)
{
return false;
}
}
and my call from adobe AIR code as below
var ws:WebService = new WebService();
ws.wsdl="http://mysite.com/myservice.asmx?WSDL";
ws.useProxy=false;
ws.addEventListener(LoadEvent.LOAD,onWSDLLoad);
ws.loadWSDL();
ws.Authenticate.addEventListener(ResultEvent.RESULT,resultHandler);
ws.Authenticate.addEventListener(FaultEvent.FAULT,onLoginFaultHandler);
ws.Authenticate("usrname","password");
protected function onLoginFaultHandler(event:FaultEvent):void
{
Alert.show('Login Failed with messsage\r\n[ '+event.fault.faultString+' ]');
/* Error #1085: The element type "br" must be terminated
by the matching end-tag "</br>". */
/* checking the content value of fault event shows
same out put as http://mysite.com/myservice.asmx */
}
protected function onLoginResultHandler(event:ResultEvent):void
{
/* on success code */
}
This guy tells us following in page http://verveguy.blogspot.com/2008/07/truth-about-flex-httpservice.html
- All HTTP GET requests are stripped of headers. It's not in the Flex stack so it's probably the underlying Flash player runtime.
- All HTTP GET requests that have content type other than "application/x-www-form-url-encoded" are turned into POST requests
- All HTTP POST requests that have no actual posted data are turned into GET requests. See 1/ and 2/
- All HTTP PUT and HTTP DELETE requests are turned into POST requests. This appears to be a browser limitation that the Flash player is stuck with.
I do see my request above turns into GET, but then I DO have post values in it. OR if those are somehow are not sent or recorded by Web Service Object ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这非常简单... Flex XML 解析器使用严格的 xml 检查,因此所有标签都必须关闭。如果您可以更改 Web 服务,请将所有
标记更改为
。This is pretty simple... The Flex XML parser uses strict xml checking, so all tags must be closed. If you can change the web service, then change all
<br>
tags to<br />
.我终于自己找到了答案。原来我将 cookie 设置为“自动检测”。这意味着 AIR 将调用 URL,并且需要重定向以将 cookie/会话值保留在 URI 本身中。
现在我将其切换为 UseCookies,一切都恢复正常。我可以通过示例 Web 服务对此进行测试,并意识到是服务器端出了问题。从 AIR 到浏览器,这是 cookie 的唯一区别。
不知何故,nusoap for PHP 很聪明,知道有可用的 Web 服务的自动检测或新 URI。但 AIR 无法找到它。无论如何,感谢大家帮助我解决这个问题。
I finally found the answer myself. turns out I was having cookies set to AutoDetect. Which meant that the AIR would call a URL and it would need to redirect to keep the cookie/session value in side the URI itself.
Now I switched that to UseCookies and Everything is back to normal. I could test this from a sample web services and realized it was the server-side that was doing something wrong. And from AIR to Browser that's the only difference of cookies.
Somehow nusoap for PHP is smart to know that there is AutoDetect or New URI of the Web Services available. But AIR couldn't locate that. Anyways Thanks everyone for helping me solve this.