使用 WSDL 将 JSON 转换为 XML 请求 [英] Convert JSON to XML Request using WSDL

查看:224
本文介绍了使用 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 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆