我嘗試使用下面的命令使用Axis2 1.6(及夜間1.7),以從WSDL(本頁最底部)的Java代碼:爲什麼在使用wsdl2java時,Axis2爲複雜/序列結構中的「任何」類型返回空值?
$出口JAVA_HOME =的/ usr/JAVA /默認
$ wsdl2java.sh -uri test.wsdl -d ADB -u -S的src/mypackage的-p --noBuildXML
這適用於一些輸出警告:
[WARN]沒有對的schemaLocation進口http://microsoft.com/wsdl/types/;編譯可能會失敗
[WARN]沒有schemaLocation用於導入;彙編可能會失敗
[WARN]鍵入TimeZone缺失!
[WARN]鍵入EnumeratedValue缺失!
...
然後代碼編譯並運行正常,沒有任何例外。但是,當我調用#ListDispatches()(或#GetDispatch())時,它將獲得5個調度的數組,但每個調度中的所有數據都將具有空值,具體爲#getIdentifier(),#getClient(),每個調度的#getSupplier()等將爲空。
我相信這與BaseModel(以及EnumeratedValue和FlagValue)在模式中使用「any」類型有關。這個WSDL是由客戶提供給我們的,所以我們希望採取阻力最小的路徑。我們需要對WSDL/etc進行最少量的更改。讓這個工作?原始的XML確實有在它的值,使用該方法得到的原始XML數據:
responseItem.getOMElement(Response.MY_QNAME,OMAbstractFactory.getOMFactory()).toStringWithConsume();
我試圖改變「任何」類型(3行)是的類型的元素anyType的/字符串和除去他們完全 - 但沒有骰子。我嘗試過使用xmlbeans而不是adb,但是當我調用wsdl2java時,它只會引發格式錯誤的屬性異常。我也試過將-Eosv和-b傳遞給wsdl2java。最後,我嘗試設置各種選項:
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.ENABLE_MTOM,Constants.VALUE_FALSE);
stub._getServiceClient().getOptions().setProperty(Constants.SERVICE_TCCL,Constants.TCCL_COMPOSITE);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.CHUNKED,Constants.VALUE_FALSE);
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.ENABLE_REST,Constants.VALUE_FALSE);
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.CONTENT_TYPE,"application/x-www-form-urlencoded");
stub._getServiceClient().getOptions().setProperty(Constants.Configuration.MESSAGE_TYPE,"application/x-www-form-urlencoded");
請幫忙!謝謝!
test.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://vans.ljkco.com/webservices/suppliers/coachusa/dispatch/2011-01-01/" xmlns:s1="http://microsoft.com/wsdl/types/" 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://vans.ljkco.com/webservices/suppliers/coachusa/dispatch/2011-01-01/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://vans.ljkco.com/webservices/suppliers/coachusa/dispatch/2011-01-01/">
<s:import namespace="http://microsoft.com/wsdl/types/" />
<s:import />
<s:complexType name="Response">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Code" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Message" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Data" type="tns:ArrayOfDataItem" />
</s:sequence>
</s:complexType>
<s:complexType name="ArrayOfDataItem">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="DataItem" nillable="true" type="tns:DataItem" />
</s:sequence>
</s:complexType>
<s:complexType name="DataItem">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Value" type="s:string" />
</s:sequence>
<s:attribute name="Key" type="s:string" />
</s:complexType>
<s:element name="GetDispatch">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="id" type="s1:guid" />
<s:element minOccurs="0" maxOccurs="1" name="authNo" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="GetDispatchResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetDispatchResult" type="tns:DispatchResponseItem" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="DispatchResponseItem">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Response" type="tns:Response" />
<s:element minOccurs="0" maxOccurs="1" name="Dispatch" type="tns:Dispatch" />
</s:sequence>
</s:complexType>
<s:complexType name="Dispatch">
<s:complexContent mixed="false">
<s:extension base="tns:BaseModel">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Identifier" type="tns:Identifier" />
<s:element minOccurs="0" maxOccurs="1" name="ParentDispatch" type="tns:Identifier" />
<s:element minOccurs="0" maxOccurs="1" name="Client" type="tns:ClientItem" />
<s:element minOccurs="0" maxOccurs="1" name="Supplier" type="tns:SupplierItem" />
<s:element minOccurs="0" maxOccurs="1" name="VanBase" type="tns:VanBaseItem" />
<s:element minOccurs="0" maxOccurs="1" name="TimeZone" type="TimeZone" />
<s:element minOccurs="0" maxOccurs="1" name="Profile" type="tns:DispatchProfile" />
<s:element minOccurs="0" maxOccurs="1" name="Communication" type="tns:CommuniqueList" />
<s:element minOccurs="0" maxOccurs="1" name="Legs" type="tns:LegList" />
<s:element minOccurs="0" maxOccurs="1" name="Authorizations" type="tns:AuthorizationList" />
<s:element minOccurs="0" maxOccurs="1" name="Events" type="tns:EventList" />
<s:element minOccurs="0" maxOccurs="1" name="SupplierProfile" type="tns:SupplierProfile" />
<s:element minOccurs="0" maxOccurs="1" name="Cancellation" type="tns:CancelInfo" />
<s:element minOccurs="0" maxOccurs="1" name="Created" type="tns:CreationInfo" />
<s:element minOccurs="0" maxOccurs="1" name="Modified" type="tns:ModifiedInfo" />
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>
<s:complexType name="BaseModel" abstract="true">
<s:sequence>
<s:any minOccurs="0" maxOccurs="unbounded" />
</s:sequence>
<s:attribute name="Type" type="s:string" />
</s:complexType>
<s:complexType name="Identifier">
<s:complexContent mixed="false">
<s:extension base="tns:BaseModel">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="Id" type="s1:guid" />
<s:element minOccurs="0" maxOccurs="1" name="AuthNo" type="s:string" />
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>
<s:element name="ListDispatches">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="utcModifiedSince" type="s:dateTime" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="ListDispatchesResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ListDispatchesResult" type="tns:DispatchListResponseItem" />
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="DispatchListResponseItem">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Response" type="tns:Response" />
<s:element minOccurs="0" maxOccurs="1" name="Dispatches" type="tns:ArrayOfDispatch" />
</s:sequence>
</s:complexType>
<s:complexType name="ArrayOfDispatch">
<s:sequence>
<s:element minOccurs="0" maxOccurs="unbounded" name="Dispatch" nillable="true" type="tns:Dispatch" />
</s:sequence>
</s:complexType>
<s:complexType name="FlagInfo">
<s:complexContent mixed="false">
<s:extension base="tns:BaseModel">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="Id" type="s1:guid" />
<s:element minOccurs="0" maxOccurs="1" name="SortCode" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="Name" type="s:string" />
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>
</s:schema>
<s:schema elementFormDefault="qualified" targetNamespace="http://microsoft.com/wsdl/types/">
<s:simpleType name="guid">
<s:restriction base="s:string">
<s:pattern value="[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}" />
</s:restriction>
</s:simpleType>
</s:schema>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" id="EnumeratedValue" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="EnumeratedValue">
<xs:sequence>
<xs:any minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="Value" type="xs:int" use="required" />
</xs:complexType>
<xs:complexType name="FlagValue">
<xs:sequence>
<xs:any minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="Value" type="xs:int" use="required" />
</xs:complexType>
<xs:complexType name="TimeZone">
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="Index" type="xs:int" />
<xs:element minOccurs="0" maxOccurs="1" name="Name">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="64" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="DisplayName">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="64" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element minOccurs="0" maxOccurs="1" name="Info" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="GetDispatchSoapIn">
<wsdl:part name="parameters" element="tns:GetDispatch" />
</wsdl:message>
<wsdl:message name="GetDispatchSoapOut">
<wsdl:part name="parameters" element="tns:GetDispatchResponse" />
</wsdl:message>
<wsdl:message name="ListDispatchesSoapIn">
<wsdl:part name="parameters" element="tns:ListDispatches" />
</wsdl:message>
<wsdl:message name="ListDispatchesSoapOut">
<wsdl:part name="parameters" element="tns:ListDispatchesResponse" />
</wsdl:message>
<wsdl:portType name="DispatchSoap">
<wsdl:operation name="GetDispatchId">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><dd>Returns a unique identifier for a dispatch by its authorization number.</dd><dt><b>Parameters</b></dt><dd><table><tr><td><i>authNo:&nbsp;</i></td><td>String representing the authorization number that is a human readable identifier</td></tr></table></dd><dt><b>Returns</b></dt><dd><table><tr><td colspan='3'><i>Response Code:&nbsp;</i></td></tr><tr><td width='20'>&nbsp;</td><td><i>200 - </i></td><td>OK. Response will contain the a unique identifier for the dispatch.</td></tr><tr><td width='20'>&nbsp;</td><td><i>403 - </i></td><td>Forbidden. Assigned to a different supplier or is unassigned.</td></tr><tr><td width='20'>&nbsp;</td><td><i>404 - </i></td><td>Not Found. Dispatch was not found.</td></tr><tr><td width='20'>&nbsp;</td><td><i>500 - </i></td><td>Internal Server Error.</td></tr></table></dd><dd><table><tr><td><i>DispatchId:&nbsp;</i></td><td>The dispatch's unique identifier if successful. An empty unique identifier (00000000-0000-0000-0000-000000000000) in case of exception.</td></tr></table></dd></wsdl:documentation>
<wsdl:input message="tns:GetDispatchIdSoapIn" />
<wsdl:output message="tns:GetDispatchIdSoapOut" />
</wsdl:operation>
<wsdl:operation name="GetDispatch">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><dd>Returns a dispatch based on the dispatch's unique identifier or authorization number.</dd><dt><b>Parameters</b></dt><dd><table><tr><td><i>id:&nbsp;</i></td><td>The dispatch unique identifier</td></tr><tr><td><i>authNo:&nbsp;</i></td><td>String representing the authorization number that is a human readable identifier</td></tr></table></dd><dt><b>Returns</b></dt><dd><table><tr><td colspan='3'><i>Response Code:&nbsp;</i></td></tr><tr><td width='20'>&nbsp;</td><td><i>200 - </i></td><td>OK. Response will contain the dispatch.</td></tr><tr><td width='20'>&nbsp;</td><td><i>403 - </i></td><td>Forbidden. Assigned to a different supplier or is unassigned.</td></tr><tr><td width='20'>&nbsp;</td><td><i>404 - </i></td><td>Not Found. Dispatch was not found.</td></tr><tr><td width='20'>&nbsp;</td><td><i>500 - </i></td><td>Internal Server Error.</td></tr></table></dd><dd><table><tr><td><i>Dispatch:&nbsp;</i></td><td>The associated dispatch if successful. Null (or Nothing) in case of exception.</td></tr></table></dd></wsdl:documentation>
<wsdl:input message="tns:GetDispatchSoapIn" />
<wsdl:output message="tns:GetDispatchSoapOut" />
</wsdl:operation>
<wsdl:operation name="ListDispatches">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><dd>Returns a list of active dispatches that have been modified since the provided date and time.</dd><dt><b>Parameters</b></dt><dd><table><tr><td><i>lastUtcModifiedTime:&nbsp;</i></td><td>The UTC date and time that a dispatch was last modified.</td></tr></table></dd><dt><b>Returns</b></dt><dd><table><tr><td colspan='3'><i>Response Code:&nbsp;</i></td></tr><tr><td width='20'>&nbsp;</td><td><i>200 - </i></td><td>OK. Response will contain the list of dispatches.</td></tr><tr><td width='20'>&nbsp;</td><td><i>500 - </i></td><td>Internal Server Error.</td></tr></table></dd><dd><table><tr><td><i>Dispatches:&nbsp;</i></td><td>The list of dispatches if successful. Null (or Nothing) in case of exception.</td></tr></table></dd></wsdl:documentation>
<wsdl:input message="tns:ListDispatchesSoapIn" />
<wsdl:output message="tns:ListDispatchesSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="DispatchSoap" type="tns:DispatchSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="GetDispatch">
<soap:operation soapAction="http://vans.ljkco.com/webservices/suppliers/coachusa/dispatch/2011-01-01/GetDispatch" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="ListDispatches">
<soap:operation soapAction="http://vans.ljkco.com/webservices/suppliers/coachusa/dispatch/2011-01-01/ListDispatches" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="DispatchSoap12" type="tns:DispatchSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="GetDispatch">
<soap12:operation soapAction="http://vans.ljkco.com/webservices/suppliers/coachusa/dispatch/2011-01-01/GetDispatch" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="ListDispatches">
<soap12:operation soapAction="http://vans.ljkco.com/webservices/suppliers/coachusa/dispatch/2011-01-01/ListDispatches" 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="Dispatch">
<wsdl:port name="DispatchSoap" binding="tns:DispatchSoap">
<soap:address location="https://demo.ljkco.com/webservices/suppliers/coachusa/dispatch.asmx" />
</wsdl:port>
<wsdl:port name="DispatchSoap12" binding="tns:DispatchSoap12">
<soap12:address location="https://demo.ljkco.com/webservices/suppliers/coachusa/dispatch.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
他們是如何改變它的?我正在使用Apache CXF和JAXB數據綁定,但我得到空內容。儘管SOAPUI能夠得到響應。 – ronnyfm