java Spring-WS无需操作即可生成WSDL

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1155809/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 15:24:51  来源:igfitidea点击:

Spring-WS generates WSDL without operations

javaweb-serviceswsdlspring-ws

提问by Etam

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

Spring-WS 生成WSDL 不需要绑定tag 的操作...你知道为什么吗?

There is my spring-ws-service.xml:

有我的 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 的 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.

提前致谢,埃塔姆。

回答by skaffman

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.

DefaultWsdl11Definition 尝试通过检查模式中的类型来自动生成 WSDL。如果您的架构不符合其预期的模式,它就不会做得很好。

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.

DefaultWsdl11Definition 从 XSD 模式构建 WSDL。此定义迭代模式中找到的所有元素元素,并为所有元素创建消息。接下来,它为所有以定义的请求或响应后缀结尾的消息创建 WSDL 操作。默认请求后缀为Request;默认的响应后缀是 Response,尽管可以通过分别设置 requestSuffix 和 responseSuffix 属性来更改这些后缀。它还基于操作构建端口类型、绑定和服务。

例如,如果我们的 Orders.xsd 架构定义了 GetOrdersRequest 和 GetOrdersResponse 元素,则 XsdBasedSoap11Wsdl4jDefinitionBuilder 将创建一个 GetOrdersRequest 和 GetOrdersResponse 消息,以及一个 GetOrders 操作,该操作放置在 Orders 端口类型中。