help: need to call call web service from java

Discussion in 'Java' started by bill sandner, Jun 30, 2004.

  1. bill sandner

    bill sandner Guest

    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
     
    bill sandner, Jun 30, 2004
    #1
    1. Advertising

  2. bill sandner

    iksrazal Guest

    (bill sandner) wrote in message news:<>...
    > 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
     
    iksrazal, Jul 1, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael Averstegge
    Replies:
    0
    Views:
    4,329
    Michael Averstegge
    Jan 10, 2006
  2. Not Me
    Replies:
    1
    Views:
    3,231
    Not Me
    Jun 5, 2007
  3. RJ
    Replies:
    4
    Views:
    824
    Brock Allen
    Sep 22, 2005
  4. Leo Violette
    Replies:
    0
    Views:
    1,107
    Leo Violette
    Apr 17, 2009
  5. Redhot
    Replies:
    0
    Views:
    785
    Redhot
    Jul 18, 2009
Loading...

Share This Page