File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Please help, Axis problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Please help, Axis problem" Watch "Please help, Axis problem" New topic
Author

Please help, Axis problem

Arash A
Greenhorn

Joined: Dec 20, 2003
Posts: 5
Hi

I appreciate if anybody can help me.

I wrote a message service using this method on the server side using Axis:

public Document method (Document body)

In a standalone java program when I have a Document object I can simply convert it to String. (String str = doc.getDocumentElement())

Here it does not work! Why?!?! How I can convert this Documnet to a String?

Thanks for any help.
Arash
Rr Kumaran
Ranch Hand

Joined: Sep 17, 2001
Posts: 548
can you please post your complete source code and other server side axis wsdd files here ...


RR Kumaran
SCJP 1.4
Arash A
Greenhorn

Joined: Dec 20, 2003
Posts: 5
Hi

Thanks for your reply.

The standalone java program is:

import org.w3c.dom.*;
import javax.xml.parsers.*;
import java.io.*;

public class DOMTest {

public static void main(String[] args) throws Exception {
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = db.parse(new File("data.xml"));
System.out.println(doc.getDocumentElement());
}
}

It prints the XML on the console.

The Message Service using Axis:

import java.io.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;

public class TVMessage {

public Document tvMessage(Document doc) {

try {

System.out.prinyln(doc.getDocumentElement());

} catch (Exception ex) {

System.out.println(ex);
}
return doc;

}
}


I will get back the proper SOAP but doesnt print the doc on console just the first element follwing with null.


I did not create wsdl and axis generated it for me.

<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl efinitions targetNamespace="http://localhost:8080/jboss-net/services/TVMessageService" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://localhost:8080/jboss-net/services/TVMessageService" xmlns:intf="http://localhost:8080/jboss-net/services/TVMessageService" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types />
<wsdl:message name="tvMessageRequest" />
- <wsdl:message name="tvMessageResponse">
<wsdl art name="tvMessageReturn" type="xsd:anyType" />
</wsdl:message>
- <wsdl ortType name="TVMessage">
- <wsdl peration name="tvMessage">
<wsdl:input message="impl:tvMessageRequest" name="tvMessageRequest" />
<wsdl utput message="impl:tvMessageResponse" name="tvMessageResponse" />
</wsdl peration>
</wsdl ortType>
- <wsdl:binding name="TVMessageServiceSoapBinding" type="impl:TVMessage">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl peration name="tvMessage">
<wsdlsoap peration soapAction="" />
- <wsdl:input name="tvMessageRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/jboss-net/services/TVMessageService" use="encoded" />
</wsdl:input>
- <wsdl utput name="tvMessageResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/jboss-net/services/TVMessageService" use="encoded" />
</wsdl utput>
</wsdl peration>
</wsdl:binding>
- <wsdl:service name="TVMessageService">
- <wsdl ort binding="impl:TVMessageServiceSoapBinding" name="TVMessageService">
<wsdlsoap:address location="http://localhost:8080/jboss-net/services/TVMessageService" />
</wsdl ort>
</wsdl:service>
</wsdl efinitions>

Thanks for your help.
Arash
Arash A
Greenhorn

Joined: Dec 20, 2003
Posts: 5
Sorry, I forgot the wsdd

<!-- Example Web Service Descriptor -->

<deployment
xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

<service name="TVMessageService" style="message" >
<parameter name="className" value="TVMessage"/>
<parameter name="allowedMethods" value="tvMessage"/>
</service>

</deployment>

Thanks.
Arash
sanker san
Ranch Hand

Joined: Dec 17, 2004
Posts: 53
try this...

import org.apache.axis.utils.XMLUtils;
...

XMLUtils utils = new XMLUtils();
System.out.println(utils.DocumentToString(doc));//doc is of type Document
 
Consider Paul's rocket mass heater.
 
subject: Please help, Axis problem
 
Similar Threads
xml doc to xml string using jaxp
Xml document to XML String
Converting Document to String
Convert Word to XML
Convert Word document to XML