以一种简单、中立的方式向HTTP发送XML。

时间:2022-04-28 17:17:23

We have some standalone devices that will send XML messages to arbitrary processing software (may be developed by us, may be 3rd party) over HTTP. The messages are relatively simple, and will conform to an existing schema. No specific reply is necessary.

我们有一些独立的设备,可以通过HTTP将XML消息发送到任意处理软件(可以由我们开发,也可以是第三方)。这些消息相对简单,并且将符合现有的模式。没有具体的答复。

I suddenly find myself lost in a world of web service technology jargon. I'd like the following:

我突然发现自己迷失在web服务技术术语的世界里。我想以下几点:

  1. To keep the devices as simple as possible, and not tied to any particular technology like SOAP (unless it's beneficial).
  2. 使设备尽可能简单,不与任何特定的技术(比如SOAP)绑定(除非它是有益的)。
  3. To make it as simple as possible to consume the messages. For instance, I could just send XML over HTTP, but then the receiver would have to manually process the message (I think). It would be great if anyone could use WSDL-like tools to easily create consumers in any language.
  4. 尽可能简单地使用这些消息。例如,我可以通过HTTP发送XML,但是接收方必须手动处理消息(我认为)。如果任何人都可以使用类似wsdl的工具来轻松地用任何语言创建使用者,那将是一件非常棒的事情。

Please help fill in the giant gaps in my understanding...and point me in the right direction. Thanks!

请帮助填补我在理解上的巨大空白……把我指向正确的方向。谢谢!

UPDATE: I should have made myself a little more clear. I'm not against using any "technology", I'm just looking for advice to strike a good balance. The standalone devices will have very limited capabilities, but enough to send an XML message over HTTP -- I don't want to complicate these things any more than I have to.

更新:我应该让自己更清楚一点。我并不反对使用任何“技术”,我只是在寻求一些建议,以达到良好的平衡。独立设备的功能将非常有限,但足以通过HTTP发送XML消息——我不想比必须的更复杂。

Then I can certainly just consume and manually process the XML messages..... but it would be neat if there was a way to generate this code (the way I can generate code from WSDL). What I've got is an .xsd describing the messages themselves, nothing more.

然后我当然可以直接消费并手动处理XML消息……但是如果有一种生成代码的方法(我可以从WSDL生成代码的方法),那就太棒了。我得到的是.xsd描述消息本身,仅此而已。

4 个解决方案

#1


1  

Following on the comment above about WADL, you can also try WSDL 2.0. While not widely adopted yet, WSDL 2.0 does contain good support for REST style services. WSDL 2.0 is supported in Apache Axis2, which I think includes support in its WSDL2Java tool.

根据上面关于WADL的评论,您还可以尝试WSDL 2.0。虽然还没有被广泛采用,但WSDL 2.0确实包含了对REST样式服务的良好支持。Apache Axis2支持WSDL 2.0,我认为它包含了WSDL2Java工具中的支持。

#2


2  

I know you said you want to stay away from particular technologies like SOAP unless they're beneficial, but one of the main benefits that well-defined technologies have are sets of tools for parsing messages in a consistent manner. Having said that, I don't think SOAP is right for you.

我知道您说过您希望远离特定的技术,比如SOAP,除非它们是有益的,但是定义良好的技术的主要好处之一是以一致的方式解析消息的一组工具。话虽如此,我认为肥皂不适合你。

I would aim for a RESTful architecture since the messages are just plain XML and there are libraries for emitting and consuming REST-style messages in a variety of languages. You can typically hit the ground running faster with REST than with comparable technologies like SOAP, but there are still paradigms to learn.

我的目标是构建一个基于rest的体系结构,因为消息只是纯XML,并且有用于在各种语言中发出和使用rest样式的消息的库。与使用类似的技术(如SOAP)相比,您通常可以使用REST以更快的速度运行,但是仍然有一些范例需要学习。

Edit: You could describe your service using WADL which describes the RESTful architecture and includes any relevant schema. You could then use the WADL2Java tool or another WADL tool to generate the endpoint stubs. I think this approach is the closes to what you want to do while leveraging your existing schemas and not having to change your client code. Here is a sample WADL file and a little bit of info on it.

编辑:您可以使用WADL描述您的服务,WADL描述RESTful架构,并包含任何相关的模式。然后可以使用WADL2Java工具或其他WADL工具生成端点存根。我认为这种方法在利用现有模式而不必更改客户端代码的同时,也接近于您想要做的事情。这是一个WADL文件示例和一些有关它的信息。

#3


1  

Could you programatically do a form post of the XML?

您可以编程地做一个XML的表单post吗?

C# Programmatic Form Post

c#编程形式

#4


1  

It seems to me that you want two contradictory things here. Anything that provides tools will be a particular technology.

在我看来,你想要两个矛盾的东西。任何提供工具的东西都是一种特殊的技术。

However one possibility is this:

然而,一种可能性是:

Apache CXF has a plain XML-over-http binding.

Apache CXF有一个简单的XML-over-http绑定。

But it won't create consumers in any language. For that I really can't suggest anything except SOAP or REST.

但它不会创造任何语言的消费者。为此,除了肥皂或休息,我真的不能提出任何建议。

#1


1  

Following on the comment above about WADL, you can also try WSDL 2.0. While not widely adopted yet, WSDL 2.0 does contain good support for REST style services. WSDL 2.0 is supported in Apache Axis2, which I think includes support in its WSDL2Java tool.

根据上面关于WADL的评论,您还可以尝试WSDL 2.0。虽然还没有被广泛采用,但WSDL 2.0确实包含了对REST样式服务的良好支持。Apache Axis2支持WSDL 2.0,我认为它包含了WSDL2Java工具中的支持。

#2


2  

I know you said you want to stay away from particular technologies like SOAP unless they're beneficial, but one of the main benefits that well-defined technologies have are sets of tools for parsing messages in a consistent manner. Having said that, I don't think SOAP is right for you.

我知道您说过您希望远离特定的技术,比如SOAP,除非它们是有益的,但是定义良好的技术的主要好处之一是以一致的方式解析消息的一组工具。话虽如此,我认为肥皂不适合你。

I would aim for a RESTful architecture since the messages are just plain XML and there are libraries for emitting and consuming REST-style messages in a variety of languages. You can typically hit the ground running faster with REST than with comparable technologies like SOAP, but there are still paradigms to learn.

我的目标是构建一个基于rest的体系结构,因为消息只是纯XML,并且有用于在各种语言中发出和使用rest样式的消息的库。与使用类似的技术(如SOAP)相比,您通常可以使用REST以更快的速度运行,但是仍然有一些范例需要学习。

Edit: You could describe your service using WADL which describes the RESTful architecture and includes any relevant schema. You could then use the WADL2Java tool or another WADL tool to generate the endpoint stubs. I think this approach is the closes to what you want to do while leveraging your existing schemas and not having to change your client code. Here is a sample WADL file and a little bit of info on it.

编辑:您可以使用WADL描述您的服务,WADL描述RESTful架构,并包含任何相关的模式。然后可以使用WADL2Java工具或其他WADL工具生成端点存根。我认为这种方法在利用现有模式而不必更改客户端代码的同时,也接近于您想要做的事情。这是一个WADL文件示例和一些有关它的信息。

#3


1  

Could you programatically do a form post of the XML?

您可以编程地做一个XML的表单post吗?

C# Programmatic Form Post

c#编程形式

#4


1  

It seems to me that you want two contradictory things here. Anything that provides tools will be a particular technology.

在我看来,你想要两个矛盾的东西。任何提供工具的东西都是一种特殊的技术。

However one possibility is this:

然而,一种可能性是:

Apache CXF has a plain XML-over-http binding.

Apache CXF有一个简单的XML-over-http绑定。

But it won't create consumers in any language. For that I really can't suggest anything except SOAP or REST.

但它不会创造任何语言的消费者。为此,除了肥皂或休息,我真的不能提出任何建议。