使用 WSDL 将 JSON 转换为 XML 请求

编程入门 行业动态 更新时间:2024-10-28 19:24:45
本文介绍了使用 WSDL 将 JSON 转换为 XML 请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个 SOAP 网络服务,它将 XML 作为输入并发送 XML 作为响应.现在我有一个与 XML 请求相同的 JSON 对象.如何将 JSON 对象转换为 XML,以便将 XML 请求发送到我的 SOAP Web 服务.我有 WSDL 文件.换句话说,我想在 SOAP 之上提供一个额外的 REST 层

I Have a SOAP web services which takes XML as input and send XML as response. Now I have a JSON object which is the same as XML request. How can I convert JSON Object to XML so that I can send the XML request to my SOAP web service. I have the WSDL file. In other terms, I wanted to provide a extra layer of REST on top of SOAP

推荐答案

JSON 对象永远不能与 XML 文档相同",因为数据模型不同.它可能包含相同的信息,但问题是没有从 JSON 到 XML 的明确映射可以保证生成您所追求的 XML 表示.

A JSON object can never be "the same as" an XML document, because the data models are different. It may hold the same information, but the problem is that there is no definitive mapping from JSON to XML that is guaranteed to produce the XML representation that you are after.

有许多库可以将 JSON 转换为 XML:试一试,但您可能需要调整"XML 以使其成为所需的形式.当然,这总是可以使用 XSLT 来完成.

There are a number of libraries available that do JSON to XML conversion: give them a try, but you will probably have to "tweak" the XML to get it into the required form. That can always be done using XSLT, of course.

如果您使用 XSLT 3.0,那么您可以在一个步骤中完成 JSON 到 XML 的转换和后续处理(调整").

If you use XSLT 3.0 then you can do the JSON to XML conversion and subsequent processing ("tweaking") in a single step.

更多推荐

使用 WSDL 将 JSON 转换为 XML 请求

本文发布于:2023-11-26 19:46:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634951.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   WSDL   JSON   XML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!