0
votes

Apache CXF 3.1.8 Codegen-cxf-plugin disable validation

I'm using Codegen-cxf-plugin in my ejb project to work as soap client.

When I try to initialize service:

private static WsProviderPortType lkService = null;

                  WsProviderService lk = new WsProviderService(new URL(AppConfig.getConfig().getProperty("lk.service")));
                    lkService = lk.getWsProviderPort();

Cxf download wsdl and xsd and check it. I want to turn this validation off. How can I do it? Is there a way to do this with annotations?

Here is generated with wsdl class:

@WebServiceClient(name = "WsProviderService", 
              wsdlLocation = "file:/C:/src/lklB2B/lkB2B_ejb/src/main/resources/wsdl/test/lk_srv.wsdl",
              targetNamespace = "http://south.rt.ru/WsProvider/") 
public class WsProviderService extends Service {

public final static URL WSDL_LOCATION;

public final static QName SERVICE = new QName("http://south.rt.ru/WsProvider/", "WsProviderService");
public final static QName WsProviderPort = new QName("http://south.rt.ru/WsProvider/", "WsProviderPort");
static {
    URL url = null;
    try {
        url = new URL("file:/C:/src/lklB2B/lkB2B_ejb/src/main/resources/wsdl/test/lk_srv.wsdl");
    } catch (MalformedURLException e) {
        java.util.logging.Logger.getLogger(WsProviderService.class.getName())
            .log(java.util.logging.Level.INFO, 
                 "Can not initialize the default wsdl from {0}", "file:/C:/src/lklB2B/lkB2B_ejb/src/main/resources/wsdl/test/lk_srv.wsdl");
    }
    WSDL_LOCATION = url;
}

public WsProviderService(URL wsdlLocation) {
    super(wsdlLocation, SERVICE);
}

public WsProviderService(URL wsdlLocation, QName serviceName) {
    super(wsdlLocation, serviceName);
}

public WsProviderService() {
    super(WSDL_LOCATION, SERVICE);
}

public WsProviderService(WebServiceFeature ... features) {
    super(WSDL_LOCATION, SERVICE, features);
}

public WsProviderService(URL wsdlLocation, WebServiceFeature ... features) {
    super(wsdlLocation, SERVICE, features);
}

public WsProviderService(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) {
    super(wsdlLocation, serviceName, features);
}    

Here is my part of my wsdl:

......

<wsdl:portType name="WsProviderPortType">
    <wsdl:operation name="UpdateStatus">
        <wsdl:input name="UpdateStatusRequest" message="tns:UpdateStatusRequest">
        </wsdl:input>
        <wsdl:output name="UpdateStatusResponse" message="tns:UpdateStatusResponse">
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="canCharge">
        <wsdl:input name="canChargeRequest" message="tns:canChargeRequest"/>
        <wsdl:output name="canChargeResponse" message="tns:canChargeResponse"/>
    </wsdl:operation>
    <wsdl:operation name="getOrder">
        <wsdl:input name="getOrderRequest" message="tns:getOrderRequest">
        </wsdl:input>
        <wsdl:output name="getOrderResponse" message="tns:getOrderResponse">
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getAvailableSIMCardsList">
        <wsdl:input name="getAvailableSIMCardsListRequest" message="tns:getAvailableSIMCardsListRequest">
        </wsdl:input>
        <wsdl:output name="getAvailableSIMCardsListResponse" message="tns:getAvailableSIMCardsListResponse">
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="updateOrderStatus">
        <wsdl:input name="updateOrderStatusRequest" message="tns:updateOrderStatusRequest">
        </wsdl:input>
        <wsdl:output name="updateOrderStatusResponse" message="tns:updateOrderStatusResponse">
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="createOrderB2B">
        <wsdl:input name="createOrderB2BRequest" message="tns:createOrderB2BRequest">
        </wsdl:input>
        <wsdl:output name="createOrderB2BResponse" message="tns:createOrderB2BResponse">
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="searchOrder">
        <wsdl:input name="searchOrderRequest" message="tns:searchOrderRequest">
        </wsdl:input>
        <wsdl:output name="searchOrderResponse" message="tns:searchOrderResponse">
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="UpdateStatusLastMileCMS">
        <wsdl:input name="UpdateStatusLastMileCMSRequest" message="tns:UpdateStatusLastMileCMSRequest">
        </wsdl:input>
        <wsdl:output name="UpdateStatusLastMileCMSResponse" message="tns:UpdateStatusLastMileCMSResponse">
        </wsdl:output>
    </wsdl:operation>
</wsdl:portType>
<wsdl:binding name="WsProviderServiceSoapBinding" type="tns:WsProviderPortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="UpdateStatus">
        <wsdl:input name="UpdateStatusRequest">
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output name="UpdateStatusResponse">
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="canCharge">
        <wsdl:input name="canChargeRequest">
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output name="canChargeResponse">
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getOrder">
        <wsdl:input name="getOrderRequest">
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output name="getOrderResponse">
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="getAvailableSIMCardsList">
        <wsdl:input name="getAvailableSIMCardsListRequest">
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output name="getAvailableSIMCardsListResponse">
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="updateOrderStatus">
        <wsdl:input name="updateOrderStatusRequest">
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output name="updateOrderStatusResponse">
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="createOrderB2B">
        <wsdl:input name="createOrderB2BRequest">
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output name="createOrderB2BResponse">
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="searchOrder">
        <wsdl:input name="searchOrderRequest">
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output name="searchOrderResponse">
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="UpdateStatusLastMileCMS">
        <wsdl:input name="UpdateStatusLastMileCMSRequest">
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output name="UpdateStatusLastMileCMSResponse">
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>
<wsdl:service name="WsProviderService">
    <wsdl:port name="WsProviderPort" binding="tns:WsProviderServiceSoapBinding">
        <soap:address location="http://lkdevel2.south.rt.ru/wsp/soap/wsprovider/lk_srv"/>
    </wsdl:port>
</wsdl:service>

Here is my pom:

</dependencies>
<properties>
    <cxf-version>3.1.8</cxf-version>
</properties>
<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <compilerArguments>
                    <endorseddirs>${endorsed.dir}</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ejb-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <ejbVersion>3.1</ejbVersion>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.1</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${endorsed.dir}</outputDirectory>
                        <silent>true</silent>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>6.0</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
<profiles>
    <profile>
        <id>test</id>
        <dependencies>
            <dependency>
                <groupId>ru.rt.mdm</groupId>
                <artifactId>fw_ejb</artifactId>
                <version>${mdm.fw.version}</version>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.cxf</groupId>
                    <artifactId>cxf-codegen-plugin</artifactId>
                    <version>3.1.8</version>
                    <executions>
                        <execution>
                            <id>generate-sources</id>
                            <phase>generate-sources</phase>
                            <configuration>
                                <sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
                                <wsdlOptions>
                                    <wsdlOption>

                                            ${basedir}/src/main/resources/wsdl/test/newordernotificationb2b_client_ep.wsdl
                                        </wsdl>
                                        <extraargs>
                                            <extraarg>-p</extraarg>
                                            <extraarg>http://result.general.rt.ru=ru.rt.general.result.mrf.center
                                            </extraarg>
                                            <extraarg>-p</extraarg>
                                            <extraarg>
                                                http://problem.result.general.rt.ru=ru.rt.general.result.mrf.center.problem
                                            </extraarg>
                                        </extraargs>
                                    </wsdlOption>

<wsdl>${basedir}/src/main/resources/wsdl/test/wsAttachment.wsdl</wsdl>
                                    </wsdlOption>-->
                                </wsdlOptions>
                            </configuration>
                            <goals>
                                <goal>wsdl2java</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
        <properties>
            <cxf-version>3.1.8</cxf-version>
            <mdm.fw.version>3.0</mdm.fw.version>
            <mdm.domain.jar>domain-3.0.jar</mdm.domain.jar>
            <service.login>testLogin</service.login>
            <service.password>testPass</service.password>
        </properties>
    </profile>
</profiles>

1
In that duplicate link, they show how you can do it via XML settings or in code - at least the code example gets you a similar effect as the annotation would!JGlass

1 Answers

0
votes

The one of the solution was to add BindingProvider in the Service class and set endpoint settings in getRequestContext() method :

        BindingProvider bp = (BindingProvider) lkService;
        bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, AppConfig.getConfig().getProperty("lk.service"));