1

我正在努力使用与 JDOM 一起使用的 Spring-WS。

代码:

    @Endpoint
    @Namespace(uri = "http://example.pl/gb/schemas", prefix = "gb")
    public class PdfCheckStatusEndPoint {
        private static final String NAMESPACE_URI = "http://example.pl/gb/schemas";

        ...    


        @PayloadRoot(namespace = NAMESPACE_URI, localPart = "PdfStatusRequest")
        @Namespace(uri = NAMESPACE_URI, prefix = "sch")
        @ResponsePayload
        public Element getPdfStatus(@XPathParam("//sch:policyNr") String policyNr) {

              org.jdom2.Namespace javaxml2Namespace = org.jdom2.Namespace.getNamespace("http://example.pl/gb/schemas");
              Element responseElement = new Element("PersonResponse", javaxml2Namespace);
              Element childElement1 = new Element("FullName");
              childElement1.setText("john doe");

              Element childElement2 = new Element("SSN");
              childElement2.setText("12345");

              responseElement.addContent(childElement1);
              responseElement.addContent(childElement2);
              return responseElement;
        }
    }

端点自行工作,但响应与预期不同:

  <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
     <env:Header/>
     <env:Body>
        <PersonResponse xmlns="http://example.pl/gb/schemas"/>
     </env:Body>
  </env:Envelope>

如您所见,没有返回子元素,只返回根元素。有任何想法吗?

4

1 回答 1

1

好像添加了这个依赖:

    <dependency>
        <groupId>com.sun.xml.messaging.saaj</groupId>
        <artifactId>saaj-impl</artifactId>
        <version>1.3.3</version>
    </dependency>

连同bean定义:

<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
    <property name="messageFactory">
        <bean class="com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl"/>
    </property>
</bean>

做这项工作。

于 2014-02-16T11:33:16.710 回答