help: need to call call web service from java

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
 
I

iksrazal

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:

Best I can tell nusoap is php only. So you need to specify which soap
engine you are using to make the java client invokation. Listing a
stacktrace is also needed. If you are using axis I might be able to
help. You might try, however, returning to Object or Object[] or
something generic to narrow the problem down.

That being said, I did a lot of custom typing with the older apache
soap and SOAPMappingRegistry. Naturally its all different with axis,
which is what I use now. Here's a couple of links that helped me along
the way:

http://www.oreillynet.com/pub/au/583
http://teaching.cs.uml.edu/~heines/tools/JRun4/docs/html/Programmers_Guide/wsadvtopix2.html#1113163
http://sys-con.com/story/?storyid=39649&DE=1

HTH

Outsource to an American programmer living in brazil!
http://www.braziloutsource.com/
iksrazal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,701
Latest member
XavierQ83

Latest Threads

Top