Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   help: need to call call web service from java (http://www.velocityreviews.com/forums/t134812-help-need-to-call-call-web-service-from-java.html)

bill sandner 06-30-2004 09:18 PM

help: need to call call web service from java
 
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

iksrazal 07-01-2004 02:57 PM

Re: help: need to call call web service from java
 
wsandner@hotmail.com (bill sandner) wrote in message news:<c3a27217.0406301318.19b67933@posting.google. com>...
> 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/t...2.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


All times are GMT. The time now is 05:15 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.