gpt4 book ai didi

.net - WebMethod 响应格式

转载 作者:行者123 更新时间:2023-12-01 14:37:00 27 4
gpt4 key购买 nike

我最近看到一个 jQuery 示例,其中对“Default.aspx/Test”进行了 POST,其中 Test 是 Default.aspx 中的 WebMethod,请求的内容类型是“application/json”。

WebMethod 的回复是 JSON 格式的。我一直认为 WebMethods 返回 SOAP 响应,但如果我正确解释了这段代码,就像我说的那样,WebMethod 返回 JSON。

它是否正确? WebMethods 是否以请求内容类型的格式返回响应?从什么时候开始可以做到这一点?总是?或者这是因为我安装了 ASP.NET AJAX?如果是这样,我可以反汇编哪些 namespace 以查看其工作原理?

我只使用 WebMethods 进行 .NET 到 .NET 的通信,它一直在 SOAP 中,并且始终编写自定义代码以根据指定所需的请求查询字符串参数以正确的格式(SOAP、JSON 或 XML)响应格式。我一直认为这种元格式功能需要 WCF。

最佳答案

它是 ASP.NET AJAX 的一部分.参见示例 Using Web Services in ASP.NET AJAX .
AJAX 客户端架构的一部分如下所示:

Call Web services by using the HTTP POST verb. A POST request has a body that contains the data that the browser sends to the server. It does not have a size limitation. Therefore, you can use a POST request when the size of the data exceeds the intrinsic size limitation for a GET request. The client serializes the request into JSON format and sends it as POST data to the server. The server deserializes the JSON data into .NET Framework types and makes the actual Web service call. During the response, the server serializes the return values and passes them back to the client, which deserializes them into JavaScript objects for processing.

关于.net - WebMethod 响应格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/625250/

27 4 0
文章推荐: javascript - 获取号码18437736874454810627
文章推荐: java - 调用notifyAll有什么好的解决方案吗?
文章推荐: x86 - int 13h 42h 在 Bochs 中不加载任何东西
文章推荐: java - 无法从 Vector 转换为 Integer