i have created a war file and save it in tomcat/webapps folder.this war file contains the code of the server that will read xml file and return it as table in a Jframe.i coded it in java and it is a web service where i create a war file after compiling the code and creating web.xml,and sun-jaxws.xml,and saving the jar files in lib directory.
when the client is running the following server i am getting an error
Exception in thread "AWT-EventQueue-0" com.sun.xml.internal.ws.protocol.soap.Mes
sageCreationException: Couldn't create SOAP message due to exception: XML reader
error: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,95]
Message: XML document structures must start and end within the same entity.


the client and server codes are written below,
server code:

package primary;
import java.io.*;
import java.net.*;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.*;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.event.*;
import java.awt.*; 
import java.awt.event.*;
import java.awt.event.WindowAdapter;
import java.awt.print.*;
import java.awt.print.PrinterException;
import javax.imageio.*;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.*;
import javax.xml.ws.Endpoint;
import java.io.Serializable;
@WebService 
public class tallyserver  {
 
@WebMethod 
public Object readtally(String s)
{Object o1=new Object();

try
                { try{
                      int total=0;
                      String s1,s2="";
                      double cashkz=0,cash$=0;
                      Vector columns;
                      Vector<Vector> data=new Vector<Vector>();
                      Vector<Vector> data1=new Vector<Vector>();
                      JFrame f=new JFrame();
                      JPanel p=new JPanel();
                      JTextField t=new JTextField(5);
                      JTextField t1=new JTextField(5);
                      JLabel j1=new JLabel("cash$");
                      JLabel j2=new JLabel("cashkz");
                      JPanel p1=new JPanel();
                      String path1="";             
                      String path="";
                      JTextField t2=new JTextField(5);
                      final JTextField t3=new JTextField(5);
                      JLabel jl=new JLabel("file name");
                     
                           path=s;
                           path1="c:\\Tally9.0\\" +path;
                           System.out.println(path1);                                                      
                           File xmlFile = new File(path1);
                                                             
                           columns = new Vector(); 
                           columns.add("name");
                           columns.add("quantity");
                           columns.add("total price");
                           SAXBuilder builder = new SAXBuilder();
                           Document document = (Document) builder.build(xmlFile);
                           Element rootNode = document.getRootElement();
                           List l1 = rootNode.getChildren("BODY");
                           Element first = (Element) l1.get(0);  
                           List l2 = first.getChildren("IMPORTDATA");
                           Element second = (Element) l2.get(0);  
                           List l3 = second.getChildren("REQUESTDATA");
                           Element third = (Element) l3.get(0); 
                           List l4 = third.getChildren("TALLYMESSAGE");  
                           for (int i = 0; i < l4.size(); i++) 
                                    {
                                      Element forth = (Element) l4.get(i);
                                      List l5 = forth.getChildren("VOUCHER");
                                      Element fifth = (Element) l5.get(0);
                                      String expected = fifth.getAttribute("VCHTYPE").getValue();
                                      if(expected.equals("Sales"))
                                            { List l10=fifth.getChildren("LEDGERENTRIES.LIST");
                                              Element seventh = (Element) l10.get(0);
                                              List l11=seventh.getChildren("AMOUNT");
                                              Element eighth = (Element) l11.get(0);
                                              String tot = eighth.getText();
                                              int spaceIndex =  tot.indexOf(' ');
                                              String value5="";
                                              value5= tot.substring(0,spaceIndex);
                                              value5=value5.substring(1,value5.length()-1); 
                                              List l6 = fifth.getChildren("ALLINVENTORYENTRIES.LIST");
                                              for (int j = 0; j < l6.size(); j++) 
                                                    {Element sixth = (Element) l6.get(j);
                                                     List l7=sixth.getChildren("STOCKITEMNAME");
                                                     List l8=sixth.getChildren("ACTUALQTY");
                                                     List l9=sixth.getChildren("AMOUNT");
                                                     Element goal=(Element) l7.get(0);
                                                     Element goal1=(Element) l8.get(0);
                                                     Element goal2=(Element) l9.get(0);
                                                     String value = goal.getText();  
                                                     String value1 = goal1.getText();  
                                                     String value2=goal2.getText();
                                                     String value4="";
                                                     int Index =  value2.indexOf(' ');
                                                     if (Index==-1)
                                                         {value4=value2;
                                                         }
                                                     else
                                                         {value4=value2.substring(0,Index);
       
                                                          }
                                                    Vector<String> row=new Vector<String>();              
                                                    row.addElement(value);
                                                    row.addElement(value1);
                                                    row.addElement(value4);
                                                   data.addElement(row);
                                                   cashkz=cashkz+Double.parseDouble(value4);
   
                                                   }
   
                                           }
                                      else if(expected.equals("Payment"))    
                                           { List payment1=fifth.getChildren("ALLLEDGERENTRIES.LIST");
                                             for (int j = 0; j < payment1.size(); j++) 
                                                  {Element paymente1 = (Element) payment1.get(j);
                                                   List payment2=paymente1.getChildren("LEDGERNAME");
                                                   Element paymente2 = (Element) payment2.get(0);
                                                   List payment3=paymente1.getChildren("AMOUNT");
                                                   Element paymente3 = (Element) payment3.get(0);
                                                   String ps,ps1;
                                                   ps=paymente2.getText();
                                                   ps1=paymente3.getText();
                                                   String value6="";
                                                   if (!ps.equals("Rocha Kz"))  
                                                         {
                                                          int Ind =  ps1.indexOf(' ');  
                                                          value6= ps1.substring(0,Ind);            
                                                          if (Ind==-1)
                                                               value6=ps1;
                                                         }
                                                   else
                                                         {int Ind =  ps1.indexOf(' ');
                                                          value6= ps1.substring(0,Ind);
                                                          value6=value6.substring(0,value6.length()-1);
                                                          cashkz=cashkz-Double.parseDouble(value6); 
                                                         }
              
                                                  Vector<String> row1=new Vector<String>();          
                                                  row1.addElement(ps);
                                                  row1.addElement(value6);
                                                  data1.addElement(row1);
              
                                                  }
                 
                                          }
                                    else if(expected.equals("Contra"))  
                                         {List contra1=fifth.getChildren("ALLLEDGERENTRIES.LIST");
                                          Element contraelement1 = (Element) contra1.get(0);
                                          List contra2=contraelement1.getChildren("AMOUNT");
                                          Element contraelement2 = (Element) contra2.get(0);
                                          String cs,cs1,cs2;
                                          cs=contraelement2.getText();
                                          int cind1 =  cs.indexOf('=');
                                          int cind2 =  cind1+6;
                                          int cind3 =  cs.indexOf(' ');
                                          if (cind3==-1)
                                                     cs2=cs;
                                          else
                                                    {
                                                     cs2= cs.substring(0,cind3);
                                                     cs2= cs2.substring(0,cs2.length()-1);
              
                                                     }
                                         if (cind1==-1)
                                                     cs1=cs;
                                         else
                                                     {
                                                      cs1= cs.substring(cind1,cind2);
                                                      cs1= cs1.substring(2,cs1.length());
              
                                                     } 
                                       cashkz=cashkz-Double.parseDouble(cs2); 
                                       cash$=Double.parseDouble(cs1);   
                                          
                                          }
 
     
                                    }



                        t.setText(Double.toString(cash$));
                        t1.setText(Double.toString(cashkz));
                        final JTable table = new JTable(data, columns);
                        Vector columns1;
                        columns1 = new Vector(); 
                        columns1.add("name");
                        columns1.add("amount");
                        final JTable table1 = new JTable(data1, columns1);
                        table1.setRowSelectionAllowed( true );
                        table1.setColumnSelectionAllowed( true );  
                        JScrollPane scrollPane1 = new JScrollPane(table1); 
                        table.setRowSelectionAllowed( true );
                        table.setColumnSelectionAllowed( true );  
                        JScrollPane scrollPane = new JScrollPane(table);                  
                        p.add( scrollPane ,BorderLayout.CENTER);
                        p.add( scrollPane1 ,BorderLayout.CENTER);
                        p.add(j1);
                        p.add(t);
                        p.add(j2);
                        p.add(t1);       
                        f.add(p);  
                        Object o=new Object();
                        o=(JFrame)f;
                        return o;              
                     
                 }
                 catch(JDOMException jdomex)
                                    {
    		                       System.out.println(jdomex.getMessage());
                                           
                                       
                                    }
              }
              catch(IOException ioException)
                                    {
                                    ioException.printStackTrace();
                                    
                                    }
return o1;
 
}
public static void main(String[] args)
{
 System.out.println("server");
}
}

client code:

import javax.xml.*;
import java.net.*;
import primary.Tallyserver;
import primary.TallyserverService;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.event.*;
import java.io.*;
import java.util.*;
import java.util.StringTokenizer;
import java.awt.*; 
import java.awt.event.*;
import java.awt.event.WindowAdapter;
import java.awt.print.*;
import java.awt.print.PrinterException;
public class tallyclient{
public static void main(String[] args){
try{
 JFrame frame=new JFrame("Tally");
 JPanel p=new JPanel();
 JButton button = new JButton("access server");
 final JTextField t=new JTextField(5);
 p.add(t);
 p.add(button);
 frame.add(p);
 frame.setSize(200,100);
 frame.setVisible(true);
 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 

button.addActionListener(new ActionListener()
    {
         public void actionPerformed(ActionEvent e)
         {    TallyserverService service=new TallyserverService();
              final Tallyserver port = service.getTallyserverPort();
               JFrame frame1=new JFrame("khaled");               
                frame1=(JFrame)port.readtally(t.getText());
               frame1.setSize(200,100);
               frame1.setVisible(true);
               frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
               
         }
    });
    
    }
catch(Exception e) {
         e.printStackTrace();
      }
}
}

i really apreciate any help

Could you post the XML ?

thanx for ur reply,i was waiting for any help,
my web service is formed of folder jax xml server,and contains folder META-INF,and WEB-INF.in WEB-INF i have the folder classes folder primary and inside it tally server .java and also in WEB-INF there is folder lib containg all jar files.
in WEB-INF i have 2 files web.xml and sun-jaxws.xml and in META-INF conext.xml and files as follows
this is my web.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee                         
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"     
version="2.4">   
<listener>
<listener-class> 
com.sun.xml.ws.transport.http.servlet.WSServletContextListener
</listener-class>
</listener>
<servlet>
<servlet-name>tallyserverservice</servlet-name>
<servlet-class>
com.sun.xml.ws.transport.http.servlet.WSServlet
</servlet-class>
</servlet>
<servlet-mapping>     
<servlet-name>tallyserverservice</servlet-name>
<url-pattern>/tally</url-pattern>
</servlet-mapping>
</web-app>

this is sun-jaxws.xml file:

<?xml version="1.0" encoding="UTF-8"?> <endpoints version="2.0" xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime">   <endpoint implementation="primary.tallyserver" name="tallyserverservice" url-pattern="/tally"/> </endpoints>

this is my context.xml file:

<?xml version="1.0" encoding="UTF-8"?> 
<Context antiJARLocking="true" path="/jax tally xml server"/>

i apreciate ur help
thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.