首页 \ 问答 \ Spring-WS端点记录文字包装/解包(Spring-WS endpoints document literal wrapping/unwrapping)

Spring-WS端点记录文字包装/解包(Spring-WS endpoints document literal wrapping/unwrapping)

我正在与希望我们使用WS-I 1.1文档/文字包装消息的系统集成。 我们有一个可行的解决方案,但似乎可以有一种更简单的方法来处理有效负载包装/解包。

我的端点如下:

@Endpoint
public class FooEndpoint
{

  @Autowired
  private FooService FooService;

  @PayloadRoot(localPart = "Foo", namespace = "http://foo/service")
  @ResponsePayload
  public JAXBElement<FooAcknowledgementType> Foo(
        @RequestPayload JAXBElement<FooRequestType> requestElement)
  {
    FooRequestType request = requestElement.getValue();
    FooAcknowledgementType response = FooService.Foo(request);

    // TODO: Find a better solution with the wrapped response
    return new JAXBElement<FooAcknowledgementType>(new QName(
          "http://foo/service", "FooAcknowledgement"),
          FooAcknowledgementType.class, null, response);
  }
}

和定义合同的WSDL如下:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:tns="http://foo/service" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns="http://www.w3.org/2000/09/xmldsig#" xmlns:ns1="http://foo/schema"
  name="Foo" targetNamespace="http://foo/service">
  <wsdl:types>
    <xsd:schema xmlns:s="http://foo/schema" targetNamespace="http://foo/service">
      <xsd:import namespace="http://foo/schema" schemaLocation="foo_types.xsd" />
      <xsd:element name="Foo" type="s:FooRequestType" />
      <xsd:element name="FooAcknowledgement" type="s:FooAcknowledgementType" />
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="FooRequest">
    <wsdl:part name="parameter" element="tns:Foo" />
  </wsdl:message>
  <wsdl:message name="FooAcknowledgement">
    <wsdl:part name="parameter" element="tns:FooAcknowledgement" />
  </wsdl:message>
  <wsdl:portType name="FooPortType">
    <wsdl:operation name="Foo">
      <wsdl:input message="tns:FooRequest" />
      <wsdl:output message="tns:FooAcknowledgement" />
    </wsdl:operation>
  </wsdl:portType>

  <wsdl:binding name="FooBinding" type="tns:FooPortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="Foo">
      <soap:operation soapAction="http://foo/serviceFoo" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="Foo">
    <wsdl:documentation>Foo web service</wsdl:documentation>
    <wsdl:port name="FooService" binding="tns:FooBinding">
      <soap:address location="http://localhost:8080/foo/services/Foo" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

我已经从上面的端点类中引用的foo_types.xsd模式生成了jaxb对象。

问题是,当我们接收文件/文字包装样式的肥皂消息时,肥皂体有效负载看起来像

<x:Foo>
  <!-- elements from s:FooRequestType -->
</x:Foo>

我们应该用肥皂体负载来回应

<x:FooAcknowledgement>
  <!-- elements from s:FooAcknowledgementType -->
</x:FooAcknowledgement>

无论如何,Spring-WS可以开箱即用吗? 我们可以使用代码来使用和生成兼容的消息,但似乎这可能不是正确的方法,因为在http://docs.spring.io/spring的春季文档中未引用此样式-ws /网站/参考/ HTML / tutorial.html#tutorial.xsd


I am integrating with a system that expects us to consume WS-I 1.1 document/literal wrapped messages. We have a working solution but it appears like there could be a simpler way to deal with payload wrapping/unwrapping.

I have an endpoint that as follows:

@Endpoint
public class FooEndpoint
{

  @Autowired
  private FooService FooService;

  @PayloadRoot(localPart = "Foo", namespace = "http://foo/service")
  @ResponsePayload
  public JAXBElement<FooAcknowledgementType> Foo(
        @RequestPayload JAXBElement<FooRequestType> requestElement)
  {
    FooRequestType request = requestElement.getValue();
    FooAcknowledgementType response = FooService.Foo(request);

    // TODO: Find a better solution with the wrapped response
    return new JAXBElement<FooAcknowledgementType>(new QName(
          "http://foo/service", "FooAcknowledgement"),
          FooAcknowledgementType.class, null, response);
  }
}

and a WSDL which defines the contract is like:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:tns="http://foo/service" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns="http://www.w3.org/2000/09/xmldsig#" xmlns:ns1="http://foo/schema"
  name="Foo" targetNamespace="http://foo/service">
  <wsdl:types>
    <xsd:schema xmlns:s="http://foo/schema" targetNamespace="http://foo/service">
      <xsd:import namespace="http://foo/schema" schemaLocation="foo_types.xsd" />
      <xsd:element name="Foo" type="s:FooRequestType" />
      <xsd:element name="FooAcknowledgement" type="s:FooAcknowledgementType" />
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="FooRequest">
    <wsdl:part name="parameter" element="tns:Foo" />
  </wsdl:message>
  <wsdl:message name="FooAcknowledgement">
    <wsdl:part name="parameter" element="tns:FooAcknowledgement" />
  </wsdl:message>
  <wsdl:portType name="FooPortType">
    <wsdl:operation name="Foo">
      <wsdl:input message="tns:FooRequest" />
      <wsdl:output message="tns:FooAcknowledgement" />
    </wsdl:operation>
  </wsdl:portType>

  <wsdl:binding name="FooBinding" type="tns:FooPortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="Foo">
      <soap:operation soapAction="http://foo/serviceFoo" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="Foo">
    <wsdl:documentation>Foo web service</wsdl:documentation>
    <wsdl:port name="FooService" binding="tns:FooBinding">
      <soap:address location="http://localhost:8080/foo/services/Foo" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

I've generated jaxb objects from the foo_types.xsd schema as referenced in the endpoint class above.

The issue is that when we receive soap messages in document/literal wrapped style the soap body payload would look like

<x:Foo>
  <!-- elements from s:FooRequestType -->
</x:Foo>

and we are expected to respond with a soap body payload like

<x:FooAcknowledgement>
  <!-- elements from s:FooAcknowledgementType -->
</x:FooAcknowledgement>

Is there anyway that the Spring-WS can handle this out of the box? We can consume and produce compliant messages with the code as it is but it seems like this might not be the right way to go about it as this style is not referenced in the spring docs at http://docs.spring.io/spring-ws/site/reference/html/tutorial.html#tutorial.xsd


原文:https://stackoverflow.com/questions/30882417
更新时间:2023-11-17 07:11

最满意答案

您可以通过执行以下操作将这些DataTemplate ResourceDictionary合并到ListView.Resources

<ListView ItemsSource="{Binding Path=Fruit}">
    <ListView.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="AppleTemplate.xaml" />
                <ResourceDictionary Source="OrangeTemplate.xaml" />
                <ResourceDictionary Source="PotatoTemplate.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </ListView.Resources>
</ListView>

然后, DataTemplate将可用于ListView 。 或者,您可以在更高级别合并这些ResourceDictionary (即您定义了ListViewUserControl XAML文件)。

您可能希望从ResourceDictionaryDataTemplate定义中删除x:Key


You could merge those DataTemplate ResourceDictionarys into ListView.Resources by doing:

<ListView ItemsSource="{Binding Path=Fruit}">
    <ListView.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="AppleTemplate.xaml" />
                <ResourceDictionary Source="OrangeTemplate.xaml" />
                <ResourceDictionary Source="PotatoTemplate.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </ListView.Resources>
</ListView>

Then, the DataTemplates will be available to ListView. Alternatively, you can merge these ResourceDictionarys at a higher level (i.e. the UserControl XAML file where you have your ListView defined).

You may want to remove x:Key from your DataTemplate definitions in ResourceDictionarys.

相关问答

更多

最新问答

更多
  • 如何检索Ember.js模型的所有属性(How to retrieve all properties of an Ember.js model)
  • maven中snapshot快照库和release发布库的区别和作用
  • arraylist中的搜索元素(Search element in arraylist)
  • 从mysli_fetch_array中获取选定的值并输出(Get selected value from mysli_fetch_array and output)
  • Windows Phone上的可用共享扩展(Available Share Extensions on Windows Phone)
  • 如何在命令提示符下将日期设置为文件名(How to set file name as date in command prompt)
  • 如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
  • 从iframe访问父页面的id元素(accessing id element of parent page from iframe)
  • linux的常用命令干什么用的
  • Feign Client + Eureka POST请求正文(Feign Client + Eureka POST request body)
  • 怎么删除禁用RHEL/CentOS 7上不需要的服务
  • 为什么Gradle运行测试两次?(Why does Gradle run tests twice?)
  • 由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)
  • 如何交换返回集中的行?(How to swap rows in a return set?)
  • 在android中的活动之间切换?(Switching between activities in android?)
  • Perforce:如何从Depot到Workspace丢失文件?(Perforce: how to get missing file from Depot to Workspace?)
  • Webform页面避免运行服务器(Webform page avoiding runat server)
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • 内存布局破解(memory layout hack)
  • 使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)
  • 我们可以有一个调度程序,你可以异步添加东西,但会同步按顺序执行吗?(Can we have a dispatcher that you can add things todo asynchronously but will be executed in that order synchronously?)
  • “FROM a,b”和“FROM a FULL OUTER JOIN b”之间有什么区别?(What is the difference between “FROM a, b” and “FROM a FULL OUTER JOIN b”?)
  • Java中的不可变类(Immutable class in Java)
  • bat批处理文件结果导出到txt
  • WordPress发布查询(WordPress post query)
  • 如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)
  • 是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)
  • 德州新起点计算机培训学校主要课程有什么?
  • GEP分段错误LLVM C ++ API(GEP segmentation fault LLVM C++ API)
  • “latin1_german1_ci”整理来自哪里?(Where is “latin1_german1_ci” collation coming from?)