How to define separate wsdl for different services in a same spring-WS project?

ⅰ亾dé卋堺 提交于 2020-01-04 14:14:22

问题


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

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.

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.

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?

Thanks in advance,

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:


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).

So this what I had:

<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>

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

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.



来源:https://stackoverflow.com/questions/18721604/how-to-define-separate-wsdl-for-different-services-in-a-same-spring-ws-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!