【问题标题】:How to give autogenerated SOAP webservice requests the same interface?如何为自动生成的 SOAP Web 服务请求提供相同的接口?
【发布时间】:2014-09-24 08:48:37
【问题描述】:

我正在使用 CXF (wsdl2java) 自动生成 soap webservice 类。

生成的soap方法来自xml标签,如:

<wsdl:message name="GetAvailabilityReq">
        <wsdl:part name="parameters" element="q1:GetAvailabilityReq"
            xmlns:q1="http://path.to./MyService" />
    </wsdl:message>

生成的网络服务将有各种方法,例如:

@WebService
public interface MyWebservice {
   @WebResult
   @WebMethod
   public AvailabilityRsp getAvailability(@WebParam AvailabilityReq req);

   @WebResult
   @WebMethod
   public BookingRsp getBooking(@WebParam BookingReq req);
}

如何将所有请求分组到同一个 interface 下?

例如AvailabilityReq implements BaseReqBookingReq implements BaseReq?或者也可以是extends

注意:所有请求不共享所提供的wsdl 文件的公共接口,但我希望生成该接口。

我可能必须在自动生成时告诉 jaxb/cxf,但是如何?

【问题讨论】:

标签: java web-services soap jaxb cxf


【解决方案1】:

解决方法是在 pom.xml 中提供以下信息:

            <dependency>
                    <groupId>org.jvnet.jaxb2_commons</groupId>
                    <artifactId>jaxb2-basics</artifactId>
                    <version>0.8.2</version>
            </dependency>

        <extraargs>
            <extraarg>-xjc-XautoInheritance</extraarg>
            <extraarg>-xjc-XautoInheritance-xmlRootElementsImplement=package.to.MyCommonInterface</extraarg>
        </extraargs>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-13
    • 1970-01-01
    • 2011-07-26
    • 1970-01-01
    相关资源
    最近更新 更多