简体   繁体   English

将复杂的SOAP请求转换为REST URI

[英]Converting complex SOAP requests to REST URIs

I am trying to create a REST web service which provides the exact same functionality as an existing SOAP based web service. 我正在尝试创建一个REST Web服务,它提供与现有的基于SOAP的Web服务完全相同的功能。 Some soap requests can be quite complex and I am having trouble figuring out how these could be mapped to URIs. 一些肥皂请求可能非常复杂,我很难弄清楚如何将其映射到URI。 For example the following SOAP method body represents a search: 例如,以下SOAP方法主体表示搜索:

    <HLRequest>
        <HLSearch correlId=”1”>
        <criteria numHLs="10" Level="AND" matchAll="true" exactHitCount="true" suppTemp="true" suppHLOnly="true" chainHLOnly="true" startDate="2011-01-01T00:00:00" endDate="2011-01-07T23:59:59">>
            <symbols>
                <symbol>CSCO</symbol>
                <symbol>IBM</symbol>
                <symbol>MSFT</symbol>
            </symbols>
        </criteria>
        </HLSearch>
        <HLSearch correlId=”2”>
        <criteria numHLs="10">
            <symbols>
                <symbol>GOOG</symbol>
            </symbols>
        </criteria>

         </HLSearch>
    </HLRequest>

So I need to construct a method which handles URIs with an indefinite number of repeating query parameters and I'm not sure how/if this can be done within the REST paradigm. 因此,我需要构造一个方法来处理带有不确定数量的重复查询参数的URI,而且我不确定如何/是否可以在REST范式中完成此操作。

Thanks in advance, Ned 预先感谢,内德

Your problem is that you're too hung up on a design pattern. 您的问题是您过于迷恋设计模式。 There are things that REST is good for, and things that it's not good for, and you've just found one of the latter. REST具有某些优点,而有些不利之处,您已经找到了后者之一。 You could come up with some scheme to map this data to a URI, but why would you want to? 您可以想出一些方案来将此数据映射到URI,但是为什么要这么做呢? What problem would that solve? 那会解决什么问题? For this data, XML is probably the best way to represent it, so why not just post the XML? 对于此数据,XML可能是表示它的最佳方式,那么为什么不仅仅发布XML?

Do you really need to map them all to URIs? 您是否真的需要将它们全部映射到URI? A better approach for complex data is to make some json and post that. 处理复杂数据的更好方法是制作一些json并将其发布。 Apache CXF JAX-RS support can them automatically map that to bean classes. Apache CXF JAX-RS支持可以使它们自动将其映射到Bean类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM