【问题标题】:Better way of implementing Spring webservices实现 Spring Web 服务的更好方法
【发布时间】:2023-03-24 11:14:02
【问题描述】:

我发现编写 XML 配置来定义 Spring Web 服务非常困难且多余。

示例:
公开 WSDL

&ltbean id="addService" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition" p:portTypeName="add" p:locationUri="http://localhost:9080/WebServiceExample/" p:requestSuffix="-request" p:responseSuffix="-response"> &ltproperty name="模式"> &ltbean class="org.springframework.xml.xsd.SimpleXsdSchema" p:xsd="classpath:/WEB-INF/Addition.xsd" /> &lt/属性> &ltproperty name="targetNamespace" value="addition.apps" />

对于 JAXB 上下文(定义编组器和解组器)

&ltbean class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter"> &ltproperty name="marshaller" ref="marshaller" /> &ltproperty name="unmarshaller" ref="marshaller" /> &lt/豆> &ltbean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"> &ltproperty name="contextPath" value="apps.addition">&lt/property> &lt/豆> &ltbean id="wsTemplate" class="org.springframework.ws.client.core.WebServiceTemplate"> &ltproperty name="marshaller" ref="marshaller" /> &ltproperty name="unmarshaller" ref="marshaller" /> &lt/豆>

假设我需要在一个应用程序中实现 100 个 Web 服务,那么所涉及的复杂性是多少。
您能否建议我减少此配置的正确方法。任何注释驱动的方法?
提前致谢

【问题讨论】:

  • 你看过 JAX-WS 还是一定是 Spring?

标签: java web-services spring


【解决方案1】:

Springboot 提供了支持创建webservice 的简便方法。 它减少了spring mvc(xml配置)等配置部分。

https://spring.io/projects/spring-boot

https://spring.io/guides/gs/spring-boot/

【讨论】:

    【解决方案2】:

    JAX-WS 和 JAXB 都支持注解,并且受 Spring Framework 支持

    http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/remoting.html

    JAX-WS(很久以前)有一个使用 Spring 配置的参考实现

    http://www.springsource.org/node/396

    更多关于 JAX-WS http://java.sun.com/developer/technicalArticles/J2SE/jax_ws_2/

    Spring WS 也有自己的注解支持

    http://static.springsource.org/spring-ws/site/reference/html/server.html

    更多关于 Spring WS 和 JAX-WS 的区别

    http://forum.springsource.org/showthread.php?77968-Spring-WS-vs-JAX-WS

    如果你因为“契约优先”的方式而喜欢 Spring WS,那么看看这个

    http://rphgoossens.wordpress.com/2011/02/20/developing-a-contract-first-jax-ws-webservice/

    【讨论】:

      猜你喜欢
      • 2012-01-01
      • 2011-09-18
      • 1970-01-01
      • 1970-01-01
      • 2012-05-06
      • 1970-01-01
      • 2015-09-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多