Spring-WS generates WSDL without operations

2019-06-15 22:31发布

问题:

Spring-WS generates WSDL without operations in binding tag... Do you know why?

There is my spring-ws-service.xml:

    <import resource="classpath*:application-context.xml" />

    <!-- Register PayloadRootAnnotationMethodEndpointMapping -->
    <bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping" />

    <!-- Register Endpoint -->
    <bean id="tasktablerServiceEndpoint" class="tasktabler.mpk.service.TasktablerServiceEndpoint" />

    <!-- Configure XML Marshaller -->
    <bean class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter">
        <constructor-arg ref="marshaller" />
    </bean>

    <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
        <property name="classesToBeBound">
            <list>
                <value>tasktabler.mpk.databinding.OptimizeRequest</value>
            </list>
        </property>
    </bean>

    <!-- Add automatic WSDL generation support -->
    <bean id="tasktabler" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
        <property name="schema" ref="schema" />
        <property name="portTypeName" value="tasktabler" />
        <property name="locationUri" value="http://localhost:8080/tasktabler" />
        <property name="targetNamespace" value="http://tasktabler" />
    </bean>

    <bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
        <property name="xsd" value="/WEB-INF/schema.xsd" />
    </bean>

And there is wsdl binding part of WSDL:

   <wsdl:binding name="tasktablerSoap11" type="tns:tasktabler">
      <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
   </wsdl:binding>

Thanks in advance, Etam.

回答1:

DefaultWsdl11Definition attempts to auto-generate the WSDL by examining the types in your schema. If your schema doesn't fit its expected patterns, it won't do a good job of it.

From the documentation:

The DefaultWsdl11Definition which builds a WSDL from a XSD schema. This definition iterates over all element elements found in the schema, and creates a message for all elements. Next, it creates WSDL operation for all messages that end with the defined request or response suffix. The default request suffix is Request; the default response suffix is Response, though these can be changed by setting the requestSuffix and responseSuffix properties, respectively. It also builds a portType, binding, and service based on the operations.

For instance, if our Orders.xsd schema defines the GetOrdersRequest and GetOrdersResponse elements, the XsdBasedSoap11Wsdl4jDefinitionBuilder will create a GetOrdersRequest and GetOrdersResponse message, and a GetOrders operation, which is put in a Orders port type.