从 Flex 调用 HTTPS Web 服务
我有一个 https .net 网络服务。使用soap UI 等工具调用Web 方法效果很好。我无法从 flex 调用 webmethod。我的 WSDL 在 Flex 中加载得很好。
在部署时,我的 Flex 应用程序和 Web 服务位于同一服务器上。当使用机器 url 并从服务器内部访问时,它工作正常,但当我对 Flex 应用程序使用 https url 时,则不行。
例如 - http://machinename/flex/flexApp.html 与 https://publicname/wservice/ws.asmx 但 https://publicname/flex/flexapp.html 无法工作。
我已制定具有完全访问权限的跨域策略,并且在服务器上也有有效的 SSL 证书。
当我在调试模式下从本地计算机进行调用时,我在 Fiddler 中看到以下内容 -
WSDL 调用正常并正确返回,协议显示为 HTTPS,而后面的 webmethod 调用则将协议显示为 HTTP 并返回出现错误 - 我已经坚持这个问题有一段时间了。非常感谢任何帮助。
谢谢, 尼基尔。
这是调用它的 Flex 代码:
//business delegate
public function BusinessDelegate(responder : IResponder):void
{
_responder = responder;
_service = ServiceLocator.getInstance().getService("sqlWebService");
_service.loadWSDL();
}
//Login User
public function Login(userId:String,password:String):void
{
var asyncToken:AsyncToken = _service.LoginUser(userId,password);
asyncToken.addResponder(_responder);
}
并且服务定位器具有以下标记,我将外部的 URL 设置为 https://...。
<mx:WebService
id="sqlWebService"
useProxy="false"
concurrency="multiple"
showBusyCursor="true"
wsdl="{Url}"/>
I have an https .net webservice. Invoking web methods using tools like soap UI works fine. I am unable to invoke the webmethod from flex. My WSDL loads up fine in flex.
On deployment my flex application and the webservice are on the same server. When use the machine url and access from within the server it works fine, but not when I use the https url for the flex application.
Eg - http://machinename/flex/flexApp.html works fine with https://publicname/wservice/ws.asmx but https://publicname/flex/flexapp.html fails to work.
I have the crossdomain policy in place with full access and also I have a valid SSL certificate on the server.
When I make the call from my local machine in debug mode I see the following in Fiddler-
The WSDL call goes fine and returns back correctly and the Protocol is shown as HTTPS where as the webmethod call following it shows the protocol as HTTP and returns back with the error -
I have been stuck on this for quite some time. Any help is greatly appreciated.
Thanks,
Nikhil.
Here is my Flex code that calls it:
//business delegate
public function BusinessDelegate(responder : IResponder):void
{
_responder = responder;
_service = ServiceLocator.getInstance().getService("sqlWebService");
_service.loadWSDL();
}
//Login User
public function Login(userId:String,password:String):void
{
var asyncToken:AsyncToken = _service.LoginUser(userId,password);
asyncToken.addResponder(_responder);
}
and the service locator has the following tag where I set the URL from outside as https://....
<mx:WebService
id="sqlWebService"
useProxy="false"
concurrency="multiple"
showBusyCursor="true"
wsdl="{Url}"/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我终于能够通过将调用 Flex WebService 对象的代码替换为为 Web 服务生成的特定类来解决此问题。
我使用 Import WebService(WSDL) 为 webservice 生成了类,并在运行时将主类上的 url 设置为 https://.....
它的工作原理就像一个魅力...我在 fiddler 中看到了它显示我正确地使用 HTTPS 而不是 HTTP。
这对我有帮助 -
http://livedocs.adobe.com/flex/3 /html/help.html?content=security2_15.html
由 ned 发表评论。
感谢 Flextras.com 为我指明了正确的方向。
已解决。
I finally was able to resolve this problem by replacing the code where I call the Flex WebService object with the specific generated classes for the webservice.
I generated classes for the webservice using Import WebService(WSDL) and was setting the url on the main class on run time as https://.....
and it works like a charm...and I see that in fiddler it shows me correctly going out as HTTPS instead of the HTTP.
Here is what helped me -
http://livedocs.adobe.com/flex/3/html/help.html?content=security2_15.html
Comment by nated.
Thanks Flextras.com for pointing me to right direction.
Resolved.
如果在Flex中使用WCF服务和WebService,请使用
service.svc?wsdl 用于 HTTP 和
service.svc/wsdl?wsdl 用于 HTTPS,
If using WCF service and WebService in Flex, use
service.svc?wsdl for HTTP and
service.svc/wsdl?wsdl for HTTPS,