2012-06-11 118 views
4

只是試圖(使用XFire的使用XMLBeans的結合)WSDL客戶端生成不完整?

我能夠生成客戶端+故障信息(沒有錯誤)從WSDL文件生成Java客戶端產生,但是沒有產生輸入消息和輸出消息,這是也不會在客戶端生成操作。我的WSDL文件有什麼問題嗎?或者有什麼我錯過了?

更新:

  1. 我更新了我的測試項目的XFire here

  2. 我開始懷疑這個問題可以降低到WSDL(因爲我可以成功生成其他WSDL)。我發現這些警告,其感覺相關:

    WS-I:(BP2402)的WSDL:binding元素不使用 的soapbind:如在部分中定義的結合元件 「3 SOAP綁定」。 WSDL 1.1規範。

    WS-I:(BP2032)有缺陷的soapbind:fault元素:「name」屬性值與 父元素wsdl:fault上的「name」屬性值不匹配。描述既不使用WSDL 1.1第5節中描述的WSDL MIME綁定,也不使用WSDL SOAP綁定(如 中所述)WSDL 1.1每個wsdl:input或wsdl:output元素的第3節一個wsdl:binding的 。

  3. 剛發現soap12可能導致了這個問題。如果我將xmlns:soap =「http://schemas.xmlsoap.org/wsdl/soap12/」更改爲xmlns:soap =「http://schemas.xmlsoap.org/wsdl/soap/」並刪除soap中的soapActionRequired :操作它可以成功地生成客戶端。但是web服務目前僅在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(); 
} 

} 
+0

XFire是舊的,非標準的和不受支持的。你可能會對它的繼任者Apache CXF感到高興。 – bmargulies

+0

我知道,太糟糕了,我不得不使用這個。 – Rudy

回答

1

@Rudy如果您必須使用XFire,你可以考慮嘗試其他綁定成功h作爲JAXB綁定,看看你是否能夠正確地生成代碼。

+0

我們嘗試使用JAXB,並且我們遇到了重複元素的另一個問題(因爲模式引用了對方)。 – Rudy

+0

@Rudy你是說有多個模式,其中一些引用對方?在這種情況下,你可能會合並那些相互引用的模式。這可能是導致XMLBeans無法正確生成的相同問題。 – Wins

+0

XMLBeans生成成功(並且可以在SOAP 1.1中使用) – Rudy

相關問題