我正在开发基于Spring-WS的契约优先Web服务。我依靠Castor编组,我遇到了以下问题。

当“xmlns”时,请求被接受。名称空间在Envelope标记中定义,例如:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
                      xmlns="http://www.mycompany.com/MyService/schemas">
  <soap:Header/>
  <soap:Body>
    <doPlaceHoldRequest>
      <hold>
        <accountInfo>
          <accountNumber>123456789</accountNumber>
        </accountInfo>
        <extended>false</extended>
        <afterHours>false</afterHours>
        <amountSavings>1.00</amountSavings>
        <amountChecking>0.00</amountChecking>
      </hold>
    </doPlaceHoldRequest>
  </soap:Body>
</soap:Envelope>

但是,由Spring-WS(由XSD生成)提供的.wsdl生成的.NET和Java客户端都以下列方式形成其请求:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header/>
  <soap:Body>
    <doPlaceHoldRequest 
                xmlns="http://www.mycompany.com/MyService/schemas">
      <hold>
        <accountInfo>
          <accountNumber>123456789</accountNumber>
        </accountInfo>
        <extended>false</extended>
        <afterHours>false</afterHours>
        <amountSavings>1.00</amountSavings>
        <amountChecking>0.00</amountChecking>
      </hold>
    </doPlaceHoldRequest>
  </soap:Body>
</soap:Envelope>

这会导致Castor抛出Unmarshalling Exception。如何让Castor将这些消息识别为有效?我的WSDL(或我曾经自动生成它的XSD)可能是错的吗?

有帮助吗?

解决方案

如果你看到这个博客,我认为永远不会去其他网络服务:) http://springkbase.blogspot.com/2009/06/弹簧Web网页与 - castor.html

其他提示

我第一次使用我的第一个Spring-WS / Castor Web服务遇到了这个问题。据我所知,在某个地方某个组件以非命名空间感知的方式提取有效负载。换句话说,像doPlaceHoldRequest这样的节点成为XML文档的根,而不继承顶级命名空间声明,在上面的两种情况中,这导致了一个 在你想要的命名空间中,一个不是 - 所以一个验证对你的架构是好的,而另一个没有。

最佳解决方案似乎是涵盖所有基础。使您的XSD具有elementFormDefault =&quot; qualified&quot;,以要求所有元素都在命名空间中。然后在Castor映射中的每个map-to元素中指定ns-uri和ns-prefix。结果有点重,带有所有名称空间前缀,但是当涉及服务器组件中的延迟客户端未记录的行为时,它似乎变得不那么脆弱了。

JAX-WS返回空列表是一个很好的观点,太。 org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor 值得验证进出的内容。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top