使用 RPC/编码 Web 服务的最佳方式?

发布于 2024-12-02 16:17:11 字数 599 浏览 3 评论 0原文

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

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

我还对是否使用 JAX-RPC 来完成这项工作持怀疑态度,因为它已经过时了。 Axis 1.4 是已有 5 年历史的工具。

目前我看到这三个选项:

  1. 使用 JAX-WS javax.xml.ws.Dispatch 发送和接收 SOAP 并以某种方式解析它,一个示例
  2. 使用 JAX-RPC 并因使用过时的技术而获得不好的业力,
  3. 全部手动完成,并且恨自己以后。

这些听起来都不太好,所以如果您能提供一些好的线索,思考该怎么做以及如何解决它,我将不胜感激。

I need to consume old-school RPC/encoded WSDL webservice for my backend. At first I tried to use Apache CXF and JAX-WS for that, but JAX-WS wsimport tool doesn't eat rpc/enoded WSDL.

[ERROR] rpc/encoded wsdls are not supported in JAXWS 2.0.

I'm also in doubt about using JAX-RPC for this job, because it's way out-dated. Axis 1.4 is 5 years old tool.

Currently I see these three options:

  1. use JAX-WS javax.xml.ws.Dispatch to send and receive SOAP and parse it somehow, one example
  2. use JAX-RPC and gain bad karma for using outdated technology,
  3. do it all manually and hate myself later.

Neither of these sound too good, so I would appreciate if you could give some good leads, thought what to do and how to solve it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

沒落の蓅哖 2024-12-09 16:17:11

更新

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

尽管 Axis 1.4 可能适合您,但使用 Apache CXF 和 WSDL 技巧可能是更好的方法。


[旧答案]

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

UPDATE

My case was solved with hand editing WSDL from encoded to literal (basically under operations input and output use="literal" was the only replacement) and then I could generate stubs with Apache CXF. It could be done, because endpoint wasn't parsing RPC/encoded exactly and RPC/encoded spec XML couldn't be validated against WSDL).

Although Axis 1.4 may work for you, using Apache CXF with that little WSDL hack, may be a better way.


[Old answer]

For reference -- I opted for using JAX-RPC and Axis 1.4 this time. I generated client code and hopefully can replace it with JAX-WS implementation when service gets upgraded.

你在我安 2024-12-09 16:17:11

如果有人想(好吧,“喜欢”在这里不是正确的词;-)使用 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>

In case someone would like (well, "like" is not the right word here ;-) to use Axis 1.4, here is a maven plugin that can generate appropriate classes and Port interface.

<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>
话少情深 2024-12-09 16:17:11

我对 WS RPC 风格也有同样的问题,我有一个带有 eclipse 和 java 1.8 的 springboot 项目,这...来自提供商的 WS(这意味着我无法更改已发布的 wsdl)。

如果您使用 springboot,我将使用 org.codehaus.mojo 插件来生成源代码和作品。

  1. 将您的 wsdl 存储在本地(我将其放在 Spring 项目 Myspringproyectfolder/wsdl/servicio.wsdl 的根目录中)
  2. 在 WSDL 中,将所有文本从 use="encoded" 更改为 use="literal",如上面的响应所示
  3. 更改POM 插件将其归因于修改后的本地 WSDL,而不是原始 WSDL URL。

pom.xml

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxws-maven-plugin</artifactId>
        <version>2.6</version>
        <executions>
            <execution>
            <id>wsimport-from-jdk</id>
            <goals>
                <goal>wsimport</goal>
            </goals>
            </execution>
        </executions>
        <configuration>
            <wsdlUrls>
            <wsdlUrl>wsdl/servicio.wsdl</wsdlUrl>
    
            </wsdlUrls>
            <keep>true</keep>
            <packageName>com.cbb.facturalo.wsclient.generated</packageName>
            <sourceDestDir>src/main/java</sourceDestDir>
        </configuration>
    </plugin>

4.-运行maven/install来生成源、端口类型、对象工厂等。

I have the same problem with a WS RPC style, I have a springboot project with eclipse and java 1.8 and this... WS from a provider(It means that I can't change the published wsdl).

If you're using springboot I 'm using the org.codehaus.mojo plugin to generate the sources and works.

  1. store your wsdl in local (I put it in the root of my spring project Myspringproyectfolder/wsdl/servicio.wsdl)
  2. In the WSDL change all the text from use="encoded" to use="literal" as the upper response says
  3. Change in the POM plugin attributes the to the local WSDL modified instead of the original WSDL URL.

pom.xml

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxws-maven-plugin</artifactId>
        <version>2.6</version>
        <executions>
            <execution>
            <id>wsimport-from-jdk</id>
            <goals>
                <goal>wsimport</goal>
            </goals>
            </execution>
        </executions>
        <configuration>
            <wsdlUrls>
            <wsdlUrl>wsdl/servicio.wsdl</wsdlUrl>
    
            </wsdlUrls>
            <keep>true</keep>
            <packageName>com.cbb.facturalo.wsclient.generated</packageName>
            <sourceDestDir>src/main/java</sourceDestDir>
        </configuration>
    </plugin>

4.- run the maven/install to generate the sources, port type, object factory, etcetc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文