35

我需要为我的后端使用老式的 RPC/编码的 WSDL 网络服务。起初我尝试使用 Apache CXF 和 JAX-WS,但是 JAX-WSwsimport工具不吃 rpc/enoded WSDL。

[错误] JAXWS 2.0 不支持 rpc/编码的 wsdls。

我也对使用 JAX-RPC 来完成这项工作表示怀疑,因为它已经过时了。Axis 1.4 是 5 年前的工具。

目前我看到这三个选项:

  1. 使用 JAX-WSjavax.xml.ws.Dispatch发送和接收 SOAP 并以某种方式对其进行解析,例如
  2. 使用 JAX-RPC 并因使用过时的技术而获得恶业,
  3. 手动完成这一切,以后讨厌自己。

这些听起来都不太好,所以如果你能提供一些好的线索,我会很感激,想想该做什么以及如何解决它。

4

2 回答 2

24

更新

我的情况是通过从编码文字的手动编辑 WSDL 解决的(基本上在操作输入和输出use="literal"是唯一的替代品),然后我可以使用Apache CXF生成存根。可以这样做,因为端点没有准确解析 RPC/编码,并且 RPC/编码规范 XML 无法针对 WSDL 进行验证)。

尽管 Axis 1.4 可能对您有用,但使用 Apache CXF 和 WSDL hack 可能是更好的方法。


[旧答案]

作为参考——我这次选择使用 JAX-RPC 和 Axis 1.4。我生成了客户端代码,并希望在服务升级时可以用 JAX-WS 实现替换它。

于 2011-09-06T13:11:28.423 回答
1

如果有人想(好吧,“喜欢”在这里不是正确的词 ;-) 使用 Axis 1.4,这里有一个 maven 插件,可以生成适当的类和端口接口。

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>axistools-maven-plugin</artifactId>
            <version>1.4</version>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                    <configuration>
                        <!-- Use your .wsdl location here-->
                        <sourceDirectory>${basedir}/src/main/resources/wsdl</sourceDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
<!-- Here the libraries that you need to call the Axis WS client -->
<dependencies>
    <dependency>
        <groupId>org.apache.axis</groupId>
        <artifactId>axis</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
        <groupId>org.apache.axis</groupId>
        <artifactId>axis-jaxrpc</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>commons-discovery</groupId>
        <artifactId>commons-discovery</artifactId>
        <version>0.5</version>
    </dependency>
    <dependency>
        <groupId>axis</groupId>
        <artifactId>axis-wsdl4j</artifactId>
        <version>1.5.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.axis</groupId>
        <artifactId>axis-saaj</artifactId>
        <version>1.4</version>
    </dependency>
    <!-- activation+mail: To stop Axis generating WARNING about "Attachment support being disabled" -->
    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>activation</artifactId>
        <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4.7</version>
    </dependency>
</dependencies>
于 2018-11-22T13:23:25.770 回答