1

我不知所措,希望有人能提供帮助。我正在尝试使用 Gradle 1.6、CXF 2.7.5、Oracle JDK 1.6.0_33 和 WSDLToJava 生成 WSClient

我正在使用的 WSDL 导致静态嵌套 Java 类在构建请求对象时我无法弄清楚如何填充,为了缓解这种情况,我创建了一个自定义类,我想绑定它来代替静态嵌套类。我的自定义类旨在替换<ControlData>下面 WSDL 中与“ExportVocabulary70”操作有关的元素。

这是我在运行 WSDL2Java 时看到的错误:

XPath evaluation of
"wsdl:definitions/wsdl:types/s:schema/s:element[@name='ExportVocabulary70']/s:complexType[@name='ControlData']"
results in empty target node

我在下面粘贴了 WSDL、绑定文件、自定义类、Gradle 构建任务和控制台输出。为冗长道歉,我已经尽可能多地剪掉了。

我已经尝试了很多 jaxb:binding 和 jaxws:binding 的变体,以至于我数不清了,我现在已经用谷歌搜索了自己的想法,所以非常感谢这里人们的任何智慧。

干杯,

埃德

WSDL:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                  xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
                  xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
                  xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
                  xmlns:tns="http://synaptica.factiva.com/"
                  xmlns:s="http://www.w3.org/2001/XMLSchema"
                  xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
                  xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
                  targetNamespace="http://synaptica.factiva.com/"
                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified" targetNamespace="
http://synaptica.factiva.com/">
      <s:element name="ExportVocabulary70">
        <s:complexType name="ControlData">
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="ControlData">
              <s:complexType mixed="true">
                <s:sequence>
                  <s:any/>
                </s:sequence>
              </s:complexType>
            </s:element>
            <s:element minOccurs="0" maxOccurs="1" name="ReportParameters">
              <s:complexType mixed="true">
                <s:sequence>
                  <s:any/>
                </s:sequence>
              </s:complexType>
            </s:element>
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="ExportVocabulary70Response">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1"
name="ExportVocabulary70Result">
              <s:complexType mixed="true">
                <s:sequence>
                  <s:any/>
                </s:sequence>
              </s:complexType>
            </s:element>
          </s:sequence>
        </s:complexType>
      </s:element>
    </s:schema>
  </wsdl:types>

  <wsdl:message name="ExportVocabulary70SoapIn">
    <wsdl:part name="parameters" element="tns:ExportVocabulary70"/>
  </wsdl:message>
  <wsdl:message name="ExportVocabulary70SoapOut">
    <wsdl:part name="parameters" element="tns:ExportVocabulary70Response"/>
  </wsdl:message>

  <wsdl:portType name="ServiceSoap">
    <wsdl:operation name="ExportVocabulary70">
      <wsdl:input message="tns:ExportVocabulary70SoapIn"/>
      <wsdl:output message="tns:ExportVocabulary70SoapOut"/>
    </wsdl:operation>
  </wsdl:portType>

  <wsdl:binding name="ServiceSoap12" type="tns:ServiceSoap">
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="ExportVocabulary70">
      <soap12:operation soapAction="
http://synaptica.factiva.com/ExportVocabulary70" style="document"/>
      <wsdl:input>
        <soap12:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap12:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>

  <wsdl:service name="Service">
    <wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap12">
      <soap12:address location="
http://tm04syn2201-infra/webservices/service.asmx"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

绑定文件:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<bindings
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    wsdlLocation="Synaptica.wsdl"
    xmlns:s="http://www.w3.org/2001/XMLSchema"
    xmlns="http://java.sun.com/xml/ns/jaxb"
    version="2.1">
    <bindings
node="wsdl:definitions/wsdl:types/s:schema/s:element[@name='ExportVocabulary70']/s:complexType[@name='ControlData']">
      <class name="ControlBobData"/>
    </bindings>
</bindings>

自定义类:

package com.eddgrant.synaptica.api

import javax.xml.bind.annotation.XmlAccessType
import javax.xml.bind.annotation.XmlAccessorType
import javax.xml.bind.annotation.XmlElement
import javax.xml.bind.annotation.XmlRootElement

//
http://stackoverflow.com/questions/1161147/how-do-i-get-groovy-and-jaxb-to-play-nice-together
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement
class ControlData {
  @XmlElement
  Auth auth
}

@XmlRootElement
class Auth {

  @XmlElement
  String userId

  @XmlElement
  String password
}

build.gradle 摘录(Gradle 任务和依赖项:)

configurations {
  cxf
}

dependencies {
  cxf 'org.apache.cxf:apache-cxf:2.7.5'
  compile "org.codehaus.groovy:groovy-all:1.8.6"
}

task(genClientSource, type: JavaExec) {
  dependsOn(compileGroovy)
  description "Generates Java source files from the Synaptica WSDL"

  main = 'org.apache.cxf.tools.wsdlto.WSDLToJava'
  classpath = configurations.cxf
  args     '-p', "com.eddgrant.synaptica.api",
        '-wsdlLocation', "/Synaptica.wsdl",
        '-d', project.generatedSourcePath,
        '-b', 'src/main/resources/ControlData.xjb',
        '-verbose',
        //'-sn', 'MyNewServiceLaLaLa',
        project.synapticaWsdlPath
}

控制台输出(包含错误):

25-Jul-2013 16:48:58 org.apache.cxf.tools.wsdlto.core.PluginLoader
loadPlugin
INFO: Replaced default databinding source
25-Jul-2013 16:48:58 org.apache.cxf.tools.wsdlto.core.PluginLoader
loadPlugin
INFO: Replaced default databinding domsource
25-Jul-2013 16:48:58 org.apache.cxf.tools.wsdlto.core.PluginLoader
loadPlugin
INFO: Replaced default databinding staxsource
25-Jul-2013 16:48:58 org.apache.cxf.tools.wsdlto.core.PluginLoader
loadPlugin
INFO: Replaced default databinding saxsource
25-Jul-2013 16:48:58 org.apache.cxf.tools.wsdlto.core.PluginLoader
loadPlugin
INFO: Replaced default frontend jaxws
25-Jul-2013 16:48:58 org.apache.cxf.tools.wsdlto.core.PluginLoader
loadPlugin
INFO: Replaced default frontend jaxws21
25-Jul-2013 16:48:58 org.apache.cxf.tools.wsdlto.core.PluginLoader
loadPlugin
INFO: Replaced default databinding jaxb
25-Jul-2013 16:48:58 org.apache.cxf.tools.wsdlto.core.PluginLoader
loadPlugin
INFO: Replaced default databinding xmlbeans
Loading FrontEnd jaxws ...
Loading DataBinding jaxb ...
wsdl2java -p uk.co.bbc.fabric.synaptica.api -wsdlLocation /Synaptica.wsdl
-d build/generated/src/main/java -b src/main/resources/ControlData.xjb
-verbose src/main/resources/Synaptica.wsdl
wsdl2java - Apache CXF 2.7.5


WSDLToJava Error:
file:/Data/Programming/bbc-dmi-sts-workspace/em3-parent-trunk/Synaptica/SynapticaWSClient/src/main/resources/ControlData.xjb
[12,132]: XPath evaluation of
"wsdl:definitions/wsdl:types/s:schema/s:element[@name='ExportVocabulary70']/s:complexType[@name='ControlData']"
results in empty target node


org.apache.cxf.tools.common.ToolException:
file:/Data/Programming/bbc-dmi-sts-workspace/em3-parent-trunk/Synaptica/SynapticaWSClient/src/main/resources/ControlData.xjb
[12,132]: XPath evaluation of
"wsdl:definitions/wsdl:types/s:schema/s:element[@name='ExportVocabulary70']/s:complexType[@name='ControlData']"
results in empty target node
4

2 回答 2

0

尝试仅“//s:schema/s:element[@name='ExportVocabulary70']/s:complexType[@name='ControlData']”的 xpath

看看是否有帮助。

于 2013-07-31T15:44:17.603 回答
-1

请参阅--> http://cxf.apache.org/docs/wsdl-to-java.html。请导航到外部绑定。错误可能与 xpath 无关。

于 2013-09-26T08:44:13.310 回答