如何在同一个 spring-WS 项目中为不同的服务定义单独的 wsdl? [英] How to define separate wsdl for different services in a same spring-WS project?

查看:25
本文介绍了如何在同一个 spring-WS 项目中为不同的服务定义单独的 wsdl?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Spring -WS 的新手,所以我正在寻找有关 Spring Web 服务的一些建议.

I'm new to Spring -WS and so I'm looking for some suggestion on Spring web services.

我正在尝试为我的公司产品创建网络服务.有针对两个不同目标的两组服务.但我不想创建两个不同的项目,因为我不想将 2 *.war 传递给客户端,并且在较低级别也有很多相互依赖.

I'm trying to create web services for my company product. There are two sets of services for two different targets. But I don't want to create two different projects, as I don't want to pass around 2 *.war to the clients and also at lower levels have lot of mutual dependencies.

所以,我想要一些关于如何生成两个(或多个)WSDL 文件的建议/建议.因此可以从不同的位置访问两个不同的 WSDL 文件.

So, I would like some suggestion/advice on how to generate two(or multiple) WSDL files. so the two different WSDL files will be accessible from different locations.

我尝试只使用一个 servlet,创建并绑定其中的所有 bean(spring-ws-servlet.xml)并尝试创建两个不同的动态 wsdl(我创建了两个不同的架构文件并为架构"设置了不同的值).但是没有用.

I tried using only one servlet, creating and binding all the beans in it(spring-ws-servlet.xml) and tried to create two different dynamic wsdl(I created two different schema files and set different values for "schema"). But it didn't work.

那么,谁能指导我哪种方式在架构上更好并且符合最佳实践?

So, could anyone guide me which way is architecturally better and is in line with best-practises?

提前致谢,

现在,我想知道实现这一目标的最佳方法是什么.我应该在web.xml中定义两个不同的servlet并创建两组映射,还是简单地在*-servlet.xml(spring映射文件)中定义两个生成不同wsdl的bean,如果然后如何,从而只创建一组映射.

Now, I was wondering what is the best way to accomplish this. Should I define two different servlets in web.xml and create two sets of mapping, or simply define two beans that generate different wsdl in *-servlet.xml(spring mapping file),if then how, thereby creating only one set of mapping.

推荐答案

最简单的方法,我猜它是乏味的,但我所做的是为不同的 1+ 服务添加了一个新 bean;我称之为接线配置文件(也称为 application.xml、spring-config.xml).

The easiest, I guess its tedious approach but what I did was that I added a new bean for a different 1+ service in the; i call it wiring config file (also known as application.xml, spring-config.xml).

这就是我所拥有的:

<bean id="SmallBusinessAccount" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition" lazy-init="true">
    <property name="schemaCollection">
        <bean class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
            <property name="inline" value="true" />
            <property name="xsds">
                <list>
                    <value>schemas/SmallBusinessAccountSerivceOperations.xsd</value>
                </list>
            </property>
        </bean>
    </property>
    <property name="portTypeName" value="SmallBusinessAccountService"/>
    <property name="serviceName" value="SmallBusinessAccountServices" />
    <property name="locationUri" value="/endpoints"/>
</bean>

<bean id="CreditManagement" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition" lazy-init="true">
    <property name="schemaCollection">
        <bean class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
            <property name="inline" value="true" />
            <property name="xsds">
                <list>
                    <value>schemas/CreditManagementServiceOperations.xsd</value>
                </list>
            </property>
        </bean>
    </property>
    <property name="portTypeName" value="CreditManagementService"/>
    <property name="serviceName" value="CreditManagementServices" />
    <property name="locationUri" value="/endpoints"/>
</bean>

这将为同一项目中的不同服务实现生成不同的 wsdls.

This will generate different wsdls for different service implementations in a same project.

不知道有没有更好的办法;就像将服务列表注入到单个 bean 中,为每个服务生成隔离的 wsdls.

I don't know if there is a better approach; like inject list of services to a single bean that generate isolated wsdls for each of those services.

这篇关于如何在同一个 spring-WS 项目中为不同的服务定义单独的 wsdl?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆