无法使用 cxf-java2ws-plugin 生成正确的 wsdl

发布于 2024-12-29 03:48:40 字数 2756 浏览 0 评论 0原文

我正在尝试从 MyWebService 接口生成 wsdl 文件;

public interface MyWebService{
    public ResponseMessage processService(MyWSData myWSData);
}

这是 java 类

public class MyWSData extends Message {
    private String myString;
    private MyOtherClass[] myOtherClassArray;  
    private Long myLong;
}

public class MyOtherClass{
    private Long id;
    private String name;
}

pom.xml 文件

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-java2ws-plugin</artifactId>
                <version>2.4.3</version>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.cxf</groupId>
                        <artifactId>cxf-rt-frontend-jaxws</artifactId>
                        <version>2.4.3</version>
                    </dependency>
                    <dependency>
                        <groupId>org.apache.cxf</groupId>
                        <artifactId>cxf-rt-frontend-simple</artifactId>
                        <version>2.4.3</version>
                    </dependency>
                </dependencies>

                <executions>
                    <execution>
                        <id>process-classes</id>
                        <phase>process-classes</phase>
                        <configuration>
                            <className>com.ferdisonmezay.webservice.MyWebService</className>
                            <genWsdl>true</genWsdl>
                            <verbose>true</verbose>
                            <genClient>false</genClient>
                            <serviceName>MyWebService</serviceName>
                            <targetNameSpace>some-namespace-here</targetNameSpace>
                            <argline> -createxsdimports </argline>
                        </configuration>
                        <goals>
                            <goal>java2ws</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

,这是我生成的 wsdl 文件中的 : MyOtherClass 数组字段看起来为空,

<xs:complexType name="myOtherClassArray">
    <xs:sequence/>
  </xs:complexType>

应该是什么原因,或者是否有其他方法可以生成正确的 wsdl 文件,包括 MyOtherClass[]

I'm trying to generate a wsdl file from MyWebService interface;

public interface MyWebService{
    public ResponseMessage processService(MyWSData myWSData);
}

and here's the java classes

public class MyWSData extends Message {
    private String myString;
    private MyOtherClass[] myOtherClassArray;  
    private Long myLong;
}

public class MyOtherClass{
    private Long id;
    private String name;
}

and here is my pom.xml file

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-java2ws-plugin</artifactId>
                <version>2.4.3</version>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.cxf</groupId>
                        <artifactId>cxf-rt-frontend-jaxws</artifactId>
                        <version>2.4.3</version>
                    </dependency>
                    <dependency>
                        <groupId>org.apache.cxf</groupId>
                        <artifactId>cxf-rt-frontend-simple</artifactId>
                        <version>2.4.3</version>
                    </dependency>
                </dependencies>

                <executions>
                    <execution>
                        <id>process-classes</id>
                        <phase>process-classes</phase>
                        <configuration>
                            <className>com.ferdisonmezay.webservice.MyWebService</className>
                            <genWsdl>true</genWsdl>
                            <verbose>true</verbose>
                            <genClient>false</genClient>
                            <serviceName>MyWebService</serviceName>
                            <targetNameSpace>some-namespace-here</targetNameSpace>
                            <argline> -createxsdimports </argline>
                        </configuration>
                        <goals>
                            <goal>java2ws</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

in my generated wsdl file:
MyOtherClass array field looks empty

<xs:complexType name="myOtherClassArray">
    <xs:sequence/>
  </xs:complexType>

what should be the reason, or is there any other way to generate a correct wsdl file including MyOtherClass[]

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

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

发布评论

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

评论(2

爱人如己 2025-01-05 03:48:40
  1. 这是一个非常旧的 CXF 版本。

  2. 如果没有访问器,JAX-B 就无法对 MyOtherClass 执行任何操作。尝试向字段添加公共 getter 和 setter。

  1. That's a very old version of CXF.

  2. Without accessors, JAX-B can't do anything with MyOtherClass. Try adding public getters and setters to the fields.

全部不再 2025-01-05 03:48:40

有两件事:

  1. CXF 2.5.2 java2ws 不喜欢从接口生成,因为它需要一个实现来在生成的服务器中实例化。因此,从实现接口的类生成。

  2. 实现 MyWebService 的类需要用 @javax.jws.WebService 进行注释,并且该类中的方法 processService() 需要用 @javax.jws.WebMethod 进行注释 - java2ws 只会为您的方法生成 WSDL想要它。您当然可以使用 import javax.jws.WebService; 实现MyWebService的类需要用

Two things:

  1. CXF 2.5.2 java2ws doesn't like generating from interfaces, because it needs an implementation to instantiate in the generated server. So generate from a class that implements your interface.

  2. The class that implements MyWebService needs to be annotated with @javax.jws.WebService, and the method processService() in that class needs to be annotated with @javax.jws.WebMethod - java2ws will only generate WSDL for the methods you want it to. You can of course use import javax.jws.WebService; and just annotate with @WebService, etc.

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