You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by fa...@de9.ime.eb.br on 2005/09/06 15:40:14 UTC

What's the better way to exchange XML?

Hello all again,

I need now to pass XML files between Web services. I'm thinking to use DOM
Documents, so my web service method would be (Test):

public Document mirrorMethod(Document doc){
   return doc;
}

And in my client I'm calling the service:

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document documentXML = builder.parse("myXML.xml");

System.out.println(documentXML.getChildNodes().getLength());

String urlWS = "http://localhost:8080/axis/services/XMLService";
       	
Object[] params = {documentXML};
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(urlWS);
call.setOperationName("doFilter");
Document saida = (Document) call.invoke(params);

System.out.print(saida.getChildNodes().getLength());

If you see my client I should print the same values of
getChildNodes().getLength(), but it isn't happening. My service return is
always 'null'. 

Does anyone could identify why this isn't working? Is DOM Document the better
way to send and receive a XML file to a web service?

Thanks a lot for all help.

Fabrício.



----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

Re: What's the better way to exchange XML?

Posted by trebor iksrazal <ik...@yahoo.com>.
Oi fabricio, tudo bem? 

The way I usually do it - rpc wise so I'm a bit dated
-  is just send and return the xml off as a String: 

String retXml = (String) call.invoke( new Object[] {
myXml } );

DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
      factory.setNamespaceAware(true);
     
factory.setIgnoringElementContentWhitespace(false);
      DocumentBuilder builder =
factory.newDocumentBuilder();

      InputSource isXml = new InputSource (new
StringReader(retXml));
      Document doc = builder.parse(isXml);

HTH (Hope that helps), 
iksrazal

--- fabricio@de9.ime.eb.br wrote:

> Hello all again,
> 
> I need now to pass XML files between Web services.
> I'm thinking to use DOM
> Documents, so my web service method would be (Test):
> 
> public Document mirrorMethod(Document doc){
>    return doc;
> }
> 
> And in my client I'm calling the service:
> 
> DocumentBuilderFactory factory =
> DocumentBuilderFactory.newInstance();
> DocumentBuilder builder =
> factory.newDocumentBuilder();
> Document documentXML = builder.parse("myXML.xml");
> 
>
System.out.println(documentXML.getChildNodes().getLength());
> 
> String urlWS =
> "http://localhost:8080/axis/services/XMLService";
>        	
> Object[] params = {documentXML};
> Service service = new Service();
> Call call = (Call) service.createCall();
> call.setTargetEndpointAddress(urlWS);
> call.setOperationName("doFilter");
> Document saida = (Document) call.invoke(params);
> 
> System.out.print(saida.getChildNodes().getLength());
> 
> If you see my client I should print the same values
> of
> getChildNodes().getLength(), but it isn't happening.
> My service return is
> always 'null'. 
> 
> Does anyone could identify why this isn't working?
> Is DOM Document the better
> way to send and receive a XML file to a web service?
> 
> Thanks a lot for all help.
> 
> Fabrício.
> 
> 
> 
>
----------------------------------------------------------------
> This message was sent using IMP, the Internet
> Messaging Program.
> 


"None are more hopelessly enslaved than those who falsely believe they are free. -- Goethe"


	
		
______________________________________________________
Click here to donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/