简体   繁体   English

如何从包含多个服务的WSDL创建WebService?

[英]How to create WebService from WSDL with multiple services in it?

I got trouble while creating Web Service from WSDL with two Services. 从带有两个服务的WSDL创建Web服务时遇到麻烦。 Its from Eclipse IDE with Apache CXF implementation. 它来自具有Apache CXF实现的Eclipse IDE。

I could able to create Web Service and Client from WSDL when I got one Service in WSDL. 当我在WSDL中获得一项服务时,便能够从WSDL中创建Web服务和客户端。

Eclipse is giving only ONE option to create Service Name under WSDL2Java Configuration time. Eclipse仅提供一个选项来在WSDL2Java配置时间下创建服务名称。

Please suggest me, how to move on? 请建议我,如何继续?

Remove second service, and generate the client, then remove the first service and revert the second service, then generate the client again. 删除第二个服务,并生成客户端,然后删除第一个服务,并还原第二个服务,然后再次生成客户端。

On runtime, you need to pass the service end point 在运行时,您需要传递服务端点

The best and easiest way I can suggest you is to generate the services by a maven plug-in. 我建议您最好和最简单的方法是通过Maven插件生成服务。 This plug-in is also named wsdl2java and works as it should. 该插件也被命名为wsdl2java,并且可以正常工作。 I also tried some times to create the services from the WSDL in java classes with eclipse but it is not working properly. 我也试过几次用Eclipse在Java类中从WSDL创建服务,但是它不能正常工作。 With the wsdl2java plug-in in maven you can have a deeper control on the process of creating service classes. 使用Maven中的wsdl2java插件,您可以对创建服务类的过程进行更深入的控制。 This Link can help you to do it. 链接可以帮助您做到这一点。 It will look like this: 它看起来像这样:

<plugin>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-codegen-plugin</artifactId>
  <version>${cxf.version}</version>
  <executions>
    <execution>
        <id>generate-sources</id>
        <phase>generate-sources</phase>
        <configuration>
            <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
            <wsdlOptions>
                <wsdlOption>
                    <wsdl>${basedir}/src/main/resources/myService.wsdl</wsdl>
                </wsdlOption>
            </wsdlOptions>
        </configuration>
        <goals>
            <goal>wsdl2java</goal>
        </goals>
    </execution>
  </executions>
</plugin>

jus as a hinwise: If you are not familiar with maven just give it a try. 绝对:如果您不熟悉Maven,请尝试一下。 It is easier than you think! 这比您想像的要容易! and saves you lots of time. 并节省您很多时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM