B
bill sandner
I need to write a Java client that consumes a Web Service that was
written by someone else. The service is written in php using NuSoap.
They are returning a somewhat complicated structure of arrays, and I
am having trouble deserializing them in the Java client. Their
structure is as such:
<xsd:complexType name="AllNames">
<xsd:all>
<xsd:element name="scientificNames"
type="tns:ScientificNameArray"/>
<xsd:element name="serviceData" type="tns:serviceData"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="ScientificNameArray">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType"
wsdl:arrayType="tns:ScientificName[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="ScientificName">
<xsd:all>
<xsd:element name="namebankID" type="xsd:int"/>
<xsd:element name="nameString" type="xsd:string"/>
<xsd:element name="authorityString" type="xsd:string"/>
<xsd:element name="packageID" type="xsd:int"/>
<xsd:element name="packageName" type="xsd:string"/>
<xsd:element name="rankName" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="serviceData">
<xsd:all>
<xsd:element name="currentVersion" type="xsd:string"/>
<xsd:element name="dateStamp" type="xsd:string"/>
<xsd:element name="timeStamp" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
I how do I map this on the client side? I initially tried this:
public class AllNames {
ScientificName[] scientificNames;
public class ServiceData {
public String currentVersion;
public String dateStamp;
public String timeStamp;
}
private class ScientificName{
public int namebankID;
public String nameString;
public String authorityString;
public int packageID;
public String packageName;
public String rankName;
}
}
with a BeanSerializer:
BeanSerializer beanSer = new BeanSerializer();
smr.mapTypes(Constants.NS_URI_SOAP_ENC,
new QName ("urn:uBioServiceWSDL", "AllNames"),
AllNames.class,
beanSer,
beanSer);
and tried to get the return type as such:
Parameter result = response.getReturnValue();
AllNames allNames = (AllNames)result.getValue();
Thanks for you help,
Bill Sandner
written by someone else. The service is written in php using NuSoap.
They are returning a somewhat complicated structure of arrays, and I
am having trouble deserializing them in the Java client. Their
structure is as such:
<xsd:complexType name="AllNames">
<xsd:all>
<xsd:element name="scientificNames"
type="tns:ScientificNameArray"/>
<xsd:element name="serviceData" type="tns:serviceData"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="ScientificNameArray">
<xsd:complexContent>
<xsd:restriction base="SOAP-ENC:Array">
<xsd:attribute ref="SOAP-ENC:arrayType"
wsdl:arrayType="tns:ScientificName[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="ScientificName">
<xsd:all>
<xsd:element name="namebankID" type="xsd:int"/>
<xsd:element name="nameString" type="xsd:string"/>
<xsd:element name="authorityString" type="xsd:string"/>
<xsd:element name="packageID" type="xsd:int"/>
<xsd:element name="packageName" type="xsd:string"/>
<xsd:element name="rankName" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="serviceData">
<xsd:all>
<xsd:element name="currentVersion" type="xsd:string"/>
<xsd:element name="dateStamp" type="xsd:string"/>
<xsd:element name="timeStamp" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
I how do I map this on the client side? I initially tried this:
public class AllNames {
ScientificName[] scientificNames;
public class ServiceData {
public String currentVersion;
public String dateStamp;
public String timeStamp;
}
private class ScientificName{
public int namebankID;
public String nameString;
public String authorityString;
public int packageID;
public String packageName;
public String rankName;
}
}
with a BeanSerializer:
BeanSerializer beanSer = new BeanSerializer();
smr.mapTypes(Constants.NS_URI_SOAP_ENC,
new QName ("urn:uBioServiceWSDL", "AllNames"),
AllNames.class,
beanSer,
beanSer);
and tried to get the return type as such:
Parameter result = response.getReturnValue();
AllNames allNames = (AllNames)result.getValue();
Thanks for you help,
Bill Sandner