如何使用 JAX-WS 和 Maven 生成 SOAP 1.2 版本端点

Cha*_*ney 5 soap wsdl web-services jax-ws maven

所以我试图使用带有 JAX-WS 的 SOAP 1.2 版的 WSDL,但是它只会生成 1.1 版。我正在使用 Maven 来使用 WSDL。使用 WSDL 的 POM 文件如下所示。

   <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxws-maven-plugin</artifactId>
    <version>1.10</version>

    <executions>
      <execution>
       <goals>
          <goal>wsimport</goal>
        </goals>
        <configuration>
          <wsdlFiles>
            <wsdlFile>MEAI_OnlineServices.webServices.Volubill_selfCare_04.wsdl</wsdlFile>
          </wsdlFiles>
          <bindingDirectory>${basedir}/src/wsdl</bindingDirectory>
          <extension>true</extension>
          <protocol>Xsoap1.2</protocol>            
        </configuration>
      </execution>

    </executions>

  </plugin>
Run Code Online (Sandbox Code Playgroud)

以下是来自 WSDL 的片段

   <wsdl:definitions name="selfCare" targetNamespace="http://eaidev.mobinil.com/MEAI_OnlineServices/webServices/Volubill/selfCare" 
   xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
   xmlns:soapjms="http://www.w3.org/2008/07/soap/bindings/JMS/" 
   xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
   xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
   xmlns:tns="http://eaidev.mobinil.com/MEAI_OnlineServices/webServices/Volubill/selfC
   are" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
   xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 
   xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/">
Run Code Online (Sandbox Code Playgroud)

然后在宣布操作时,我有以下内容。

    <soap12:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="deleteBucket">
  <soap12:operation soapAction="MEAI_OnlineServices_webServices_Volubill_selfCare_Binder_deleteBucket" style="document"/>
  <wsdl:input>
    <soap12:body parts="parameters" use="literal"/>
  </wsdl:input>
  <wsdl:output>
    <soap12:body parts="parameters" use="literal"/>
  </wsdl:output>
</wsdl:operation>
Run Code Online (Sandbox Code Playgroud)

我无法设法让这个建筑成为 1.2 版本。我有 2 个绑定文件,如下所示,它们将阻止 WSDL 的一部分生成 void 方法而不是返回方法。

jaxb-binding.xml

   <?xml version="1.0" encoding="UTF-8"?>
   <!-- Prevent any Strings being changed to a JAXBE<String> element -->
<jaxb:bindings version="2.1" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <jaxb:globalBindings generateElementProperty="false" />     
</jaxb:bindings>
Run Code Online (Sandbox Code Playgroud)

和 bindings.xml

  <?xml version="1.0" encoding="UTF-8"?>
   <bindings xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
wsdlLocation="MEAI_OnlineServices.webServices.Volubill_selfCare_04.wsdl"
xmlns="http://java.sun.com/xml/ns/jaxws">
<!-- Disable default wrapper style -->
<enableWrapperStyle>false</enableWrapperStyle>  
<endpoints xmlns='http://java.sun.com/xml/ns/jax-ws/ri/runtime' version='2.0'>
<endpoint binding="http://java.sun.com/xml/ns/jaxws/2003/05/soap/bindings/HTTP/"/>
</endpoints>
Run Code Online (Sandbox Code Playgroud)

bindings 类中的端点试图让它生成 SOAP 1.2,但我没有成功。

无论如何知道如何解决这个问题吗?如果需要更多代码,请告诉我。提前致谢。

小智 0

以下配置对我有用:

      <plugin>
            <groupId>com.helger.maven</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>2.6.1</version>
            <executions>
                <execution>
                    <id>periodictableaccessws</id>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <configuration>
                        <wsdlDirectory>src/main/resources</wsdlDirectory>
                        <wsdlFiles>
                            <wsdlFile>your_wsdl.wsdl</wsdlFile>
                        </wsdlFiles>
                        <packageName>your.target.package
                        </packageName>
                        <target>2.1</target>
                        <keep>true</keep>
                        <verbose>true</verbose>
                        <extension>true</extension>
                    </configuration>
                </execution>
            </executions>
        </plugin>
Run Code Online (Sandbox Code Playgroud)