2015-06-05 3 views
1

Я пытаюсь включить файл привязки JAXB при использовании плагина CXF XJC для вызова wsdl2java. Так что я на самом деле я генерации WSDL и использованиеИнтеграция файла привязки jaxb с использованием CXF для генерации клиента на основе WSDL

-createxsdimports

для создания внешних файлов схемы, так что я могу затем выполнить команду JAXB привязки для данного конкретного файла, а затем необходимости использовать JAXWS связывания. Я ищу некоторую помощь на ошибки я получаю или альтернативного решения, такие как использование связывания JAXWS файла без экспортирования и т.д.

Вот мой WSDL:

<?xml version="1.0" encoding="UTF-8"?> 
<wsdl:definitions name="TestImplService" targetNamespace="http://service.logging.a/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://service.logging.a/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> 
    <wsdl:types> 
<schema xmlns="http://www.w3.org/2001/XMLSchema"> 
    <import namespace="http://service.logging.a/" schemaLocation="TestImpl_schema1.xsd"/> 
</schema> 
    </wsdl:types> 
    <wsdl:message name="method"> 
    <wsdl:part name="parameters" element="tns:method"> 
    </wsdl:part> 
    </wsdl:message> 
    <wsdl:message name="methodResponse"> 
    <wsdl:part name="parameters" element="tns:methodResponse"> 
    </wsdl:part> 
    </wsdl:message> 
    <wsdl:portType name="Test"> 
    <wsdl:operation name="method"> 
     <wsdl:input name="method" message="tns:method"> 
    </wsdl:input> 
     <wsdl:output name="methodResponse" message="tns:methodResponse"> 
    </wsdl:output> 
    </wsdl:operation> 
    </wsdl:portType> 
    <wsdl:binding name="TestImplServiceSoapBinding" type="tns:Test"> 
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 
    <wsdl:operation name="method"> 
     <soap:operation soapAction="" style="document"/> 
     <wsdl:input name="method"> 
     <soap:body use="literal"/> 
     </wsdl:input> 
     <wsdl:output name="methodResponse"> 
     <soap:body use="literal"/> 
     </wsdl:output> 
    </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:service name="TestImplService"> 
    <wsdl:port name="TestImplPort" binding="tns:TestImplServiceSoapBinding"> 
     <soap:address location="http://localhost:9090/TestImplPort"/> 
    </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 

Вот TestImpl_schema1.xsd:

<?xml version="1.0" encoding="utf-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://service.logging.a/" elementFormDefault="unqualified" targetNamespace="http://service.logging.a/" version="1.0"> 
<xs:element name="method" type="tns:method"/> 
<xs:element name="methodResponse" type="tns:methodResponse"/> 
<xs:complexType name="method"> 
    <xs:sequence> 
     <xs:element minOccurs="0" name="arg0" type="tns:foo"/> 
    </xs:sequence> 
    </xs:complexType> 
<xs:complexType name="foo"> 
    <xs:sequence> 
     <xs:element name="map"> 
     <xs:complexType> 
      <xs:sequence> 
      <xs:element maxOccurs="unbounded" minOccurs="0" name="entry"> 
       <xs:complexType> 
       <xs:sequence> 
        <xs:element minOccurs="0" name="key" type="xs:string"/> 
        <xs:element minOccurs="0" name="value" type="xs:anyType"/> 
       </xs:sequence> 
       </xs:complexType> 
      </xs:element> 
      </xs:sequence> 
     </xs:complexType> 
     </xs:element> 
    </xs:sequence> 
    </xs:complexType> 
<xs:complexType name="methodResponse"> 
    <xs:sequence> 
     <xs:element minOccurs="0" name="return" type="tns:foo"/> 
    </xs:sequence> 
    </xs:complexType> 
</xs:schema> 

Вот мой binding.xml файл:

<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.1"> 
    <jaxb:bindings schemaLocation="wsdl/TestImpl_schema1.xsd"> 
    <jaxb:bindings node="//xs:complexType[@name='foo']//xs:element[@name='map']"> 
     <jaxb:property> 
     <jaxb:baseType name="java.util.HashMap;" /> 
     </jaxb:property> 
    </jaxb:bindings> 
    </jaxb:bindings> 
</jaxb:bindings> 

Вот мой Maven Зависимость:

<plugin> 
    <groupId>org.apache.cxf</groupId> 
    <artifactId>cxf-codegen-plugin</artifactId> 
    <version>${cxf.version}</version> 
    <executions> 
     <execution> 
      <id>generate-sources</id> 
      <phase>generate-sources</phase> 
      <configuration> 

       <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot> 
       <wsdlOptions> 
        <wsdlOption> 
         <wsdl>${basedir}/src/main/resources/META-INF/wsdl/TestImpl.wsdl</wsdl> 
         <bindingFiles> 
          <bindingFile>${basedir}/src/main/resources/META-INF/wsdl/binding.xml</bindingFile> 
         </bindingFiles> 
        </wsdlOption> 
       </wsdlOptions> 
      </configuration> 
      <goals> 
       <goal>wsdl2java</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin> 

А вот ошибка я получаю при попытке запустить плагин:

[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:2.7.13:wsdl2java (generate-sources) on project Test-Client: Execution generate-sources of goal org.apache.cxf:cxf-codegen-plugin:2.7.13:wsdl2java failed. IllegalArgumentException: Illegal character in opaque part at index 2: C:\..\Tester-Client/src/main/resources/META-INF/wsdl/binding.xml -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles: 
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException 

ответ

0

Ничего на самом деле нужно изменить. В плагине CXF у меня был неправильный путь к моему файлу binding.xml. После исправления пути все, казалось, работало так, как ожидалось.