gpt4 book ai didi

java - Maven generatePackage 用于从模式定义生成类的 wsdl

转载 作者:行者123 更新时间:2023-12-04 12:58:34 25 4
gpt4 key购买 nike

我在 SpringBoot 中使用 Java14。
我需要基于 wsdl 生成一些 Java 类。然而,它正在生成,它将所有生成的类放在一个平面结构中,而不是放在 wsdl 中指定的包中。
如果有人可以提供一些建议,我将不胜感激。
更多详情:
POM(可以看到生成的包是 com.travellinck.client.approval )

    <build>
<plugins>
<!-- <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin> -->
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.13.2</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<generatePackage>com.travellinck.client.approval</generatePackage>
<generateDirectory>${project.basedir}/src/main/java</generateDirectory>
<schemaDirectory>${project.basedir}/src/main/resources/wsdl</schemaDirectory>
<schemaIncludes>
<include>*.wsdl</include>
</schemaIncludes>
</configuration>
</plugin>
</plugins>
</build>
WSDL
<!--  Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.5-b05 .  -->
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.5-b05 . -->
<definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.travellinck.com/client/approval/service" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://www.travellinck.com/client/approval/service" name="ApprovalService">
<types>
<xsd:schema>
<xsd:import namespace="http://www.travellinck.com/client/approval/service" schemaLocation="http://localhost:8088/approval?xsd=1"/>
</xsd:schema>
<xsd:schema>
<xsd:import namespace="http://www.travellinck.com/client/approval/evaluation/strategy" schemaLocation="http://localhost:8088/approval?xsd=2"/>
</xsd:schema>
<xsd:schema>
<xsd:import namespace="http://www.travellinck.com/client/approval/evaluation" schemaLocation="http://localhost:8088/approval?xsd=3"/>
</xsd:schema>
<xsd:schema>
<xsd:import namespace="http://www.travellinck.com/client/approval/contact" schemaLocation="http://localhost:8088/approval?xsd=4"/>
</xsd:schema>
<xsd:schema>
<xsd:import namespace="http://www.travellinck.com/client/approval" schemaLocation="http://localhost:8088/approval?xsd=5"/>
</xsd:schema>
</types>
<message name="submitRequestForApproval">
<part xmlns:ns1="http://www.travellinck.com/client/approval" name="approvalRequest" element="ns1:approvalRequest"/>
</message>
<message name="submitRequestForApprovalResponse">
<part xmlns:ns2="http://www.travellinck.com/client/approval" name="approvalResponse" element="ns2:approvalResponse"/>
</message>
<message name="UnsupportedBusinessRequest">
<part name="fault" element="tns:unsupportedBusinessRequest"/>
</message>
<message name="UnsupportedSupportingDocument">
<part name="fault" element="tns:unsupportedSupportingDocument"/>
</message>
<message name="getApprovalState">
<part xmlns:ns3="http://www.travellinck.com/client/approval" name="getApprovalStateRequest" element="ns3:getApprovalStateRequest"/>
</message>
<message name="getApprovalStateResponse">
<part xmlns:ns4="http://www.travellinck.com/client/approval" name="getApprovalStateResponse" element="ns4:getApprovalStateResponse"/>
</message>
<message name="UnknownApprovalRequest">
<part name="fault" element="tns:unknownApprovalRequest"/>
</message>
<message name="withdrawRequestForApproval">
<part xmlns:ns5="http://www.travellinck.com/client/approval" name="withdrawApprovalRequest" element="ns5:withdrawApprovalRequest"/>
</message>
<message name="withdrawRequestForApprovalResponse">
<part xmlns:ns6="http://www.travellinck.com/client/approval" name="withdrawApprovalResponse" element="ns6:withdrawApprovalResponse"/>
</message>
<message name="InvalidRequest">
<part name="fault" element="tns:invalidRequest"/>
</message>
<message name="RequestNoLongerInProgress">
<part name="fault" element="tns:requestNoLongerInProgress"/>
</message>
<portType name="Approval">
<operation name="submitRequestForApproval">
<input wsam:Action="http://www.travellinck.com/client/approval/service/Approval/submitRequestForApprovalRequest" message="tns:submitRequestForApproval"/>
<output wsam:Action="http://www.travellinck.com/client/approval/service/Approval/submitRequestForApprovalResponse" message="tns:submitRequestForApprovalResponse"/>
<fault message="tns:UnsupportedBusinessRequest" name="UnsupportedBusinessRequest" wsam:Action="http://www.travellinck.com/client/approval/service/Approval/submitRequestForApproval/Fault/UnsupportedBusinessRequest"/>
<fault message="tns:UnsupportedSupportingDocument" name="UnsupportedSupportingDocument" wsam:Action="http://www.travellinck.com/client/approval/service/Approval/submitRequestForApproval/Fault/UnsupportedSupportingDocument"/>
</operation>
<operation name="getApprovalState">
<input wsam:Action="http://www.travellinck.com/client/approval/service/Approval/getApprovalStateRequest" message="tns:getApprovalState"/>
<output wsam:Action="http://www.travellinck.com/client/approval/service/Approval/getApprovalStateResponse" message="tns:getApprovalStateResponse"/>
<fault message="tns:UnknownApprovalRequest" name="UnknownApprovalRequest" wsam:Action="http://www.travellinck.com/client/approval/service/Approval/getApprovalState/Fault/UnknownApprovalRequest"/>
</operation>
<operation name="withdrawRequestForApproval">
<input wsam:Action="http://www.travellinck.com/client/approval/service/Approval/withdrawRequestForApprovalRequest" message="tns:withdrawRequestForApproval"/>
<output wsam:Action="http://www.travellinck.com/client/approval/service/Approval/withdrawRequestForApprovalResponse" message="tns:withdrawRequestForApprovalResponse"/>
<fault message="tns:InvalidRequest" name="InvalidRequest" wsam:Action="http://www.travellinck.com/client/approval/service/Approval/withdrawRequestForApproval/Fault/InvalidRequest"/>
<fault message="tns:RequestNoLongerInProgress" name="RequestNoLongerInProgress" wsam:Action="http://www.travellinck.com/client/approval/service/Approval/withdrawRequestForApproval/Fault/RequestNoLongerInProgress"/>
<fault message="tns:UnknownApprovalRequest" name="UnknownApprovalRequest" wsam:Action="http://www.travellinck.com/client/approval/service/Approval/withdrawRequestForApproval/Fault/UnknownApprovalRequest"/>
</operation>
</portType>
<binding name="ApprovalPortBinding" type="tns:Approval">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="submitRequestForApproval">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="UnsupportedBusinessRequest">
<soap:fault name="UnsupportedBusinessRequest" use="literal"/>
</fault>
<fault name="UnsupportedSupportingDocument">
<soap:fault name="UnsupportedSupportingDocument" use="literal"/>
</fault>
</operation>
<operation name="getApprovalState">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="UnknownApprovalRequest">
<soap:fault name="UnknownApprovalRequest" use="literal"/>
</fault>
</operation>
<operation name="withdrawRequestForApproval">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
<fault name="InvalidRequest">
<soap:fault name="InvalidRequest" use="literal"/>
</fault>
<fault name="RequestNoLongerInProgress">
<soap:fault name="RequestNoLongerInProgress" use="literal"/>
</fault>
<fault name="UnknownApprovalRequest">
<soap:fault name="UnknownApprovalRequest" use="literal"/>
</fault>
</operation>
</binding>
<service name="ApprovalService">
<port name="ApprovalPort" binding="tns:ApprovalPortBinding">
<soap:address location="http://localhost:8088/approval"/>
</port>
</service>
</definitions>
这将生成 com.travellinck.client.approval 中的模型类包裹。
enter image description here
这是不正确的,我希望它按如下方式生成它们(这是从另一个使用 Java7 的应用程序中获取的,该应用程序从相同的 wsdl 生成模型类):
enter image description here
如您所见,这些类不是在平面结构中,而是在根据 wsdl 定义的包中:
例如
    <xsd:schema>
<xsd:import namespace="http://www.travellinck.com/client/approval/contact" schemaLocation="http://localhost:8088/approval?xsd=4"/>
</xsd:schema>
就好像忽略了 /contact .

最佳答案

我通过使用 apache.cxf 解决了这个问题

        <plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.3.7</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.basedir}/src/main/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${project.basedir}/src/main/resources/wsdl/approval.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>

关于java - Maven generatePackage 用于从模式定义生成类的 wsdl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62636121/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com