Best way to consume RPC/encoded webservice?

核能气质少年 提交于 2019-11-27 10:30:33

问题


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.


回答1:


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.




回答2:


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>


来源:https://stackoverflow.com/questions/7284126/best-way-to-consume-rpc-encoded-webservice

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