how to read ArrayOfAnyType from .Net web service using JAVA code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • klwead123
    New Member
    • Feb 2010
    • 3

    how to read ArrayOfAnyType from .Net web service using JAVA code

    i am try to read an object from .Net Webservice i got this type
    ArrayOfAnyType
    as in this lines of code:

    public class NewClass {



    try { // Call Web Service Operation
    org.tempuri.Cou ntryWS service = new org.tempuri.Cou ntryWS();
    org.tempuri.Cou ntryWSSoap port = service.getCoun tryWSSoap();
    // TODO process result here
    org.tempuri.Arr ayOfAnyType result = port.countryGet All();
    System.out.prin tln("Result = "+result);
    } catch (Exception ex) {
    // TODO handle custom exceptions here
    }

    }

    how to extract data from this Object (ArrayOfAnyType ) ???

    this Object is a collection return from .Net webservice
  • ThatThatGuy
    Recognized Expert Contributor
    • Jul 2009
    • 453

    #2
    So whats the problem in it .... it would generally return an array...

    suppose it returns an array of strings so it will appear as

    Code:
    <string>
    A
    B
    C
    D
    </string>
    parse it through Xml classes provided by java

    Comment

    • klwead123
      New Member
      • Feb 2010
      • 3

      #3
      Thanks for your reply "ThatThatGu y"
      but the problem is that the web method which is "port.countryGe tAll();" returns a collection (list) and in the java client i recieve this list object as a ArrayOfAnyType object and i couldn't extract the data from this object.
      I tried to cast the arrayofanytype:
      try { // Call Web Service Operation
      // org.tempuri.Res ervationWS service = new org.tempuri.Res ervationWS();
      // org.tempuri.Res ervationWSSoap port = service.getRese rvationWSSoap() ;
      // // TODO process result here
      // org.tempuri.Arr ayOfAnyType result = port.reservatio nGetAll();
      //
      // List<Object> list = result.getAnyTy pe();
      // _reservation[] array = (_reservation[])list.toArray(n ew _reservation[list.size()]);
      // for(int i=0;i<array.len gth;i++){
      //// _reservation res = (_reservation)l ist.get(i);
      // System.out.prin tln(array[i].getRESERVATION IDs());
      //// System.out.prin tln(res.getRESE RVATIONIDs());
      // }
      //
      //
      // } catch (Exception ex) {
      // // TODO handle custom exceptions here
      // ex.printStackTr ace();
      // }
      but it throws an exception, so i suppose its the wrong way to cast it.
      kindly give me the java code which parses it through Xml classes provided by java.
      Thanks.

      Comment

      • ThatThatGuy
        Recognized Expert Contributor
        • Jul 2009
        • 453

        #4
        you can checkout this article

        for reading xml with java

        Comment

        • klwead123
          New Member
          • Feb 2010
          • 3

          #5
          Ok now i know how to read from an xml file with java classes. The question now is how could i access the xml file (SOAP Response).

          what is the path of XML files in .Net webservices is it on the server or where?

          Comment

          Working...