【问题标题】:WSDL Client Generation not complete?WSDL 客户端生成未完成?
【发布时间】:2012-06-14 14:32:23
【问题描述】:

刚刚尝试从 WSDL 文件生成 java 客户端生成(使用 XFire 和 XMLBeans 绑定)

我能够生成客户端+故障消息(没有错误),但是没有生成输入消息和输出消息,它也没有在客户端生成操作。我的 WSDL 文件有什么问题吗,还是有什么我想念的?

更新:

  1. 我更新了我的测试 XFire 项目here

  2. 我开始怀疑问题可以被隔离到 WSDL(因为我可以成功生成其他 WSDL)。我发现了这些警告,我觉得它们是相关的:

    WS-I: (BP2402) wsdl:binding 元素不使用 soapbind:binding 元素,在“3 SOAP 绑定”部分中定义。的 WSDL 1.1 规范。

    WS-I: (BP2032) 有缺陷的soapbind:fault 元素:“name”属性值与“name”属性值不匹配 父元素 wsdl:fault.

    WS-I: (AP2901) 描述既不使用 WSDL 1.1 第 5 节中描述的 WSDL MIME 绑定,也不使用 WSDL SOAP 绑定中描述的 每个 wsdl:input 或 wsdl:output 元素的 WSDL 1.1 第 3 节 wsdl:binding.

  3. 刚刚发现soap12 可能会导致该问题。如果我将 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap12/" 更改为 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 并删除soap中的soapActionRequired :operation 可以成功生成客户端。但是webservice目前只在soap1.2中才有。所以这里不是将wsdl改成使用soap1.1。

这是我的 WSDL 文件:

<!--Created by TIBCO WSDL-->
<wsdl:definitions xmlns:tns="http://schemas.ocbc.com/soa/WSDL/service/CBS-CustAccountInfo-I" xmlns:soap1="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:jndi="http://www.tibco.com/namespaces/ws/2004/soap/apis/jndi" xmlns:ns="http://schemas.ocbc.com/soa/emf/common/envelope/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:jms="http://www.tibco.com/namespaces/ws/2004/soap/binding/JMS" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="Untitled" targetNamespace="http://schemas.ocbc.com/soa/WSDL/service/CBS-CustAccountInfo-I">

<wsdl:types>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://schemas.ocbc.com/soa/emf/common/envelope/" elementFormDefault="qualified" attributeFormDefault="unqualified">
        <xs:include schemaLocation="../Schemas/XML/CBS-CustAccountInfo-I-ServiceEnvelope.xsd"/>
    </xs:schema>
</wsdl:types>
<wsdl:service name="CBS-CustAccountInfo-I">
    <wsdl:port name="CBS-CustAccountInfo-I_HTTP" binding="tns:CBS-CustAccountInfo-I_HTTPBinding">
        <soap:address location="https://localhost:15038/Services/CBS-CustAccountInfo-I/Processes/MainRequestResponse_HTTP"/>
    </wsdl:port>
</wsdl:service>
<wsdl:portType name="PortType">
    <wsdl:operation name="CBS-CustAccountInfo-I">
        <wsdl:input message="tns:InputMessage"/>
        <wsdl:output message="tns:OutputMessage"/>
        <wsdl:fault name="fault1" message="tns:FaultMessage"/>
    </wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CBS-CustAccountInfo-I_HTTPBinding" type="tns:PortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="CBS-CustAccountInfo-I">
        <soap:operation style="document" soapAction="/Services/CBS-CustAccountInfo-I/Processes/MainRequestResponse_HTTP" soapActionRequired="true"/>
        <wsdl:input>
            <soap:body use="literal" parts="InputMessage"/>
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal" parts="OutputMessage"/>
        </wsdl:output>
        <wsdl:fault name="fault1">
            <soap:fault use="literal" name="fault1"/>
        </wsdl:fault>
    </wsdl:operation>
</wsdl:binding>
<wsdl:message name="InputMessage">
    <wsdl:part name="InputMessage" element="ns:ServiceEnvelope"/>
</wsdl:message>
<wsdl:message name="OutputMessage">
    <wsdl:part name="OutputMessage" element="ns:ServiceEnvelope"/>
</wsdl:message>
<wsdl:message name="FaultMessage">
    <wsdl:part name="FaultMessage" element="ns:ServiceEnvelope"/>
</wsdl:message>
</wsdl:definitions>

这是我要生成的 ant 任务:

<!-- Generating XML Beans -->   
<target name="gen-xmlbeans">
<java classname="org.apache.xmlbeans.impl.tool.SchemaCompiler"
          classpathref="build.classpath"
          fork="true">
      <arg value="-out"/>
      <arg value="${basedir}/lib/ocbc.jar"/>
      <arg value="${schema.path}"/>
</java>
</target>

<!-- Generating Client -->
<target name="ws-generate">
        <taskdef name="wsgen" classname="org.codehaus.xfire.gen.WsGenTask">
            <classpath>
                <fileset dir="${lib.dir}" includes="*.jar" />
            </classpath>    
        </taskdef>    
        <wsgen outputDirectory="${basedir}/src/" wsdl="${wsdl.path}" package="test.client" overwrite="true" binding="xmlbeans"/>                
</target>

生成的客户端:

public class CBS_CustAccountInfo_IClient {

private static XFireProxyFactory proxyFactory = new XFireProxyFactory();
private HashMap endpoints = new HashMap();

public CBS_CustAccountInfo_IClient() {
}

public Object getEndpoint(Endpoint endpoint) {
    try {
        return proxyFactory.create((endpoint).getBinding(), (endpoint).getUrl());
    } catch (MalformedURLException e) {
        throw new XFireRuntimeException("Invalid URL", e);
    }
}

public Object getEndpoint(QName name) {
    Endpoint endpoint = ((Endpoint) endpoints.get((name)));
    if ((endpoint) == null) {
        throw new IllegalStateException("No such endpoint!");
    }
    return getEndpoint((endpoint));
}

public Collection getEndpoints() {
    return endpoints.values();
}

}

【问题讨论】:

  • XFire 是旧的、非标准的并且不受支持。您可能对 Apache CXF(它的继任者)更满意。
  • 我知道,可惜我不得不用这个。

标签: web-services wsdl tibco xfire


【解决方案1】:

@Rudy 如果您必须使用 XFire,您可能会考虑尝试其他绑定,例如 JAXB 绑定,看看您是否能够正确生成代码。

【讨论】:

  • 我们尝试使用 JAXB,但我们遇到了重复元素的另一个问题(因为模式相互引用)。
  • @Rudy 你是说有多个模式并且其中一些相互引用吗?在那种情况下,您是否可能合并那些相互引用的模式。这可能与导致 XMLBeans 无法正确生成的问题相同。
  • XMLBeans 生成成功(可以在 SOAP 1.1 中使用)
猜你喜欢
  • 2013-08-20
  • 1970-01-01
  • 2015-09-09
  • 2012-12-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-02
相关资源
最近更新 更多