Announcement Announcement Module
No announcement yet.
Possible with spring-ws, wsdl message element defined by xsd type instead of element? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Possible with spring-ws, wsdl message element defined by xsd type instead of element?

    I have a schema provided by a third party vendor. This schema does not follow the spring-ws convention whereby each wsdl message is defined by an XML Schema element. Rather, the message part is defined using an XML Schema complexType directly.

    The style is as follows

    HTML Code:
     <wsdl:message name="registerDevice">
      <wsdl:part name="registrationData" type="schema:nBIDeviceRegistrationData"/>
    whereas spring-ws convention is to use an intermediary xsd element

    HTML Code:
    <xs:element name="RegisterDeviceRequest" type="nBIDeviceRegistrationData"/>
    <wsdl:message name="RegisterDeviceRequest">
            <wsdl:part name="registrationData" element="schema:RegisterDeviceRequest" />
    Is there any way to configure spring-ws, with JAXB Marshalling to work with this wsdl as-is?

    The problem i am hitting is that JAXB is only creating java objects for the types that are defined in the schemas inside the wsdl:types, and not for the wsdl:message elements.

    I can configure my endpoint with the appropriate @PayloadRoot, accepting the nBIDeviceRegistrationData object, but when this is passed all it's fields are null. The nBIDeviceRegistrationData is an @XMLType but not an @XmlRootElement.

    As a workaround i can edit the wsdl, and add elements to the XML Schema that mirror the wsdl:message definitions, but i would prefer to use the wsdl as-is, as manual modifications are error prone and slow down the round-trip between releases.

    Is there a way to make JAXB generate classes for the wsdl:message elements?

  • #2
    I guess this is not supported?


    • #3
      In theory it should be supported. However you probably need some tweaks due to the missing @XmlRootElement. Instead of the actual element try JAXBElement<nBIDeviceRegistrationData> as a type.


      • #4

        Have tried your suggestion, unfortunately the supplied NBIDeviceRegistrationData jaxb object is still all null values.

            public void registerDevice(@RequestPayload JAXBElement<NBIDeviceRegistrationData> registration) {
        Also, it turns out i over simplified the problem, the message has two parts:

        HTML Code:
         <message name="registerDevice">
          <part xmlns:partns="java:com.alcatel.hdm.service.nbi.dto" type="partns:NBIDeviceRegistrationData" name="nBIDeviceRegistrationData">
          <part xmlns:partns="" type="partns:long" name="longVal">
        So not sure how i could access both without having jaxb generate an object to represent the wsdl:message element with it's two parts?

        What i have been doing is adding this element to the schema, which matches what is sent on the wire, even though the wdsl:message defintion does not refer to it.
        HTML Code:
           <s:element name="registerDevice">
              <s:element name="nBIDeviceRegistrationData" type="dto:NBIDeviceRegistrationData"/>
              <s:element name="longVal" type="s:long"/>
        And Jaxb magically demarshalls into it, and spring-ws is able to find my payload handler for it.

        Looking at my end-goal, another approach might be to define this element in a separate xsd, and have jaxb merge it in, that way the wsdl definitions doesn't need any modifications. But not sure if jaxb can do that.