DJ,

The easiest way for me to pass XML documents through SOAP is to convert the XML into a 
string, pass it over the wire and then recreate the XML.  The code snippets below show 
how to do that using JDOM.

//Client code
    File f = new File("SampleLocate.xml");
    SAXBuilder builder = new SAXBuilder();
    Document doc = builder.build(f);

    XMLOutputter out = new XMLOutputter();
    String request = out.outputString(doc);
    
    // set up SOAP Call object here.    

    Vector params = new Vector();
    params.addElement(new Parameter("request", String.class, request, null));
    call.setParams(params);

//Here is what happens on the server side
    StringReader sr = new StringReader(request);
    SAXBuilder builder = new SAXBuilder(false);
    Document requestDoc = builder.build(sr);

// Back at the ranch on the client
      Response resp = call.invoke(url, "");
      Parameter p = resp.getReturnValue();
      String returnedXML = p.toString();

Then you can recreate the XML on the client just as was done on the server.  This is 
probably not the cleanest way to achieve passing XML docs, but it is easy and works 
well with JDOM.

HTH,

Harris


-----Original Message-----
From: "Khanmamedov Djavad (NET/Dallas)" <[EMAIL PROTECTED]>
Date: Tue, 18 Sep 2001 13:41:35 -0500
To:  <[EMAIL PROTECTED]>
Subject: Retrieving complex XML structures from SOAP body


> Hi:
>  
> I am trying to retrieve the following structure from the SOAP body but
> SOAP returns nulls as parameter lists.  Can somebody help ?
> I would appreciate any suggestion on how to extract the stuff from
> inside body as a string, string[] or anything else.  I would prefer to
> parse the contents myself, instead of writing deserializers.
>  
> Thanks,
> DJ
>  
>  
> ====================================
>  
>  
> HTTP/1.1 200 OK
> Content-Type: text/xml; charset="utf-8"
> Content-Length: nnnn
>  
> <SOAP-ENV:Envelope
>  xmlns:SOAP-ENV=" http://schemas.xmlsoap.org/soap/envelope/";
>  xmlns:xsi=" http://www.w3.org/1999/XMLSchema-instance";
>  xmlns:xsd=" http://www.w3.org/1999/XMLSchema";
>  xmlns:ais="urn:application-interface-service#version-1.0"
>  SOAP-ENV:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/";>
>  
>     <SOAP-ENV:Header> 
>     blah-blah-blah
>     </SOAP-ENV:Header>
>  
>     <SOAP-ENV:Body>
>     
>         <DataSpace>Selection</DataSpace>
>         <DataObject>Address</DataObject>
>         <Sequence>
>             <SequenceItem>
>               <DataObject>Address</DataObject>
>               <AttributeList>
>                     <Name>SI</Name>
>                     <Building>Karaportti 2</Building>
>                     <POBox>360</POBox>
>                     <Street></Street>
>                     <Town>Espoo</Town>
>                     <City></City>
>                     <Region></Region>
>                     <AreaCode>FIN-00045</AreaCode>
>                     <Country>Finland</Country>
>               </AttributeList>
>              </SequenceItem>
>         <Sequence>
>         
>     </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
>  
>  
>  
> 

-- 

_______________________________________________
Have you downloaded the latest calling software from Net2Phone? Click here to get it 
now!

http://www.net2phone.com/cgi-bin/adforward.cgi?p_key=NH211JK&url=http://commcenter.net2phone.com/





Reply via email to