“处理”;任何;使用java的wsdl模式中的字段
我使用“wsimport”成功地用wsdl生成了我的pojo类。但是wsdl模式有“any”字段。这些字段在我的java类中生成为“对象” wsdl模式:“处理”;任何;使用java的wsdl模式中的字段,java,web-services,soap,wsimport,Java,Web Services,Soap,Wsimport,我使用“wsimport”成功地用wsdl生成了我的pojo类。但是wsdl模式有“any”字段。这些字段在我的java类中生成为“对象” wsdl模式: <s:complexType name="Model1"> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="Model2"> <s:complexType> <s:sequen
<s:complexType name="Model1">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Model2">
<s:complexType>
<s:sequence>
<s:any minOccurs="0" maxOccurs="unbounded" namespace="http://www.w3.org/2001/XMLSchema" processContents="lax"/>
<s:any minOccurs="1" namespace="urn:schemas-microsoft-com:xml-diffgram-v1" processContents="lax"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element minOccurs="0" maxOccurs="1" name="Response" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Response_Str" type="s:string"/>
</s:sequence>
</s:complexType>
...
...
Model2的模式响应如下:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<Response xmlns="...">
<Result>
<Model2>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Temp" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Temp">
<xs:complexType>
<xs:sequence>
<xs:element name="field1" type="xs:int" minOccurs="0"/>
<xs:element name="field2" msdata:DataType="System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs:string" minOccurs="0"/>
...
...
...
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<Temp diffgr:id="Temp1" msdata:rowOrder="0">
<ID>20018243</ID>
...
...
...
20018243
Wsdl不存在Model2的模式,但该模式在响应中
如何在java中处理模式
如何将响应转换为“对象模型2” 我不认为您可以用Java处理这个问题,至少不能用标准工具。使用了大量的Microsoft扩展。我怀疑.NET之外的任何东西都不会理解它。也许我可以使用自定义xml解析器,但这将是一个非常脆弱的解决方案。该模式提供的保证很少。如果成功解析了一个响应,并不意味着下一个响应可以工作。如果可能,尝试获得另一个更可移植的API。
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<Response xmlns="...">
<Result>
<Model2>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Temp" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Temp">
<xs:complexType>
<xs:sequence>
<xs:element name="field1" type="xs:int" minOccurs="0"/>
<xs:element name="field2" msdata:DataType="System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs:string" minOccurs="0"/>
...
...
...
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<NewDataSet xmlns="">
<Temp diffgr:id="Temp1" msdata:rowOrder="0">
<ID>20018243</ID>