从 Silverlight 调用 JSP

发布于 2024-10-15 05:49:12 字数 500 浏览 2 评论 0原文

我们有一个用Java开发的网站,JSP运行在apache服务器上。

出于可用性原因,决定设计一个 Silverlight Web 应用程序并从 silverlight

http 请求调用 JSP URL,例如 http://mydomain.myapp.com/transaction/transactionlist.jsp 将以 JSON 格式返回响应。

我认为可以使用 System.web.httprequest 和关联的类从 Silverlight 调用这些 JSP URL,并使用 .net JSON 基类解析 JSON 响应。

但我只想知道这种做法是否正确。

我尝试调用 JSP url,当我收到协议违规异常时,提示通用“由于对象的当前状态,该操作无效。没有找到任何其他可以帮助我的信息。任何评论/指导都是真的赞赏。

We have a website developed in Java, JSP runs in a apache server.

For Usability reasons it was decided to design a Silverlight web application and invoke the JSP URLs from silverlight

http requests such as http://mydomain.myapp.com/transaction/transactionlist.jsp would return the response in JSON format.

I was thinking that its possible to invoke these JSP URLs from Silverlight using System.web.httprequest and associated classes and parse the JSON response using the .net JSON base classes.

But I just want to know if this approach is correct.

I tried invoking a JSP url and the moment I got an Protocol Violation exception saying a generic "The operation is not valid due to the current state of the object. Did not find any other information that can help me. Any comments/Guidance is really appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

赠我空喜 2024-10-22 05:49:12

请参阅问题。当然可以做你正在做的事情,但你需要正确配置 HttpWebRequest。具体来说:

Uri uri = new Uri("http://mydomain.myapp.com/transaction/transactionlist.jsp");
HttpWebRequest webRequest = (HttpWebRequest)WebRequestCreator.ClientHttp.Create(uri);
webRequest.Accept = "application/json";  // Key

See this question. It's certainly possible to do what you're doing, but you need to get the HttpWebRequest configured correctly. Specifically:

Uri uri = new Uri("http://mydomain.myapp.com/transaction/transactionlist.jsp");
HttpWebRequest webRequest = (HttpWebRequest)WebRequestCreator.ClientHttp.Create(uri);
webRequest.Accept = "application/json";  // Key
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文