Cxf 3.1.8 как отключить проверку схемы

Apache CXF 3.1.8 Codegen-cxf-plugin отключить проверку

Я использую Codegen-cxf-plugin в своем проекте ejb для работы в качестве мыльного клиента.

Когда я пытаюсь инициализировать службу:

private static WsProviderPortType lkService = null;

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

Cxf загрузите wsdl и xsd и проверьте их. Я хочу отключить эту проверку. Как мне это сделать? Есть ли способ сделать это с помощью аннотаций?

Здесь создается с помощью класса wsdl:

@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);
}    

Вот моя часть моего 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>

Вот мой помпон:

</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>

В этой повторяющейся ссылке они показывают, как это можно сделать с помощью настроек XML или в коде - по крайней мере, пример кода дает вам тот же эффект, что и аннотация!

JGlass 11.04.2018 16:37
0
2
1 779
1

Ответы 1

Одним из решений было добавить BindingProvider в класс Service и установить параметры конечной точки в методе getRequestContext ():

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

Другие вопросы по теме