2 Replies Latest reply on Nov 7, 2005 9:43 AM by 843834

    saaj - running out of ideas

    843834
      Running J2SE 1.4.2 I need to write a standalone SOAP client.

      Compiles fine, but getting lots of runtime errors. Some MessageFactory does not find some Impl class..
      I install, JAXM just to find out that now some other parts are missing.
      Can somebody please tell me what API's to install to get it to work.

      Already I have installed and my CLASSPATH is pointing to:
      saaj-api.jar(also tried with saaj-1_2-fr-api.jar (difference?)), saaj-impl.jar, mail.jar, imap.jar, mailapi.jar, pop3.jar, smtp.jar, jaxm-api.jar, jaxm-runtime.jar

      Please help.
        • 1. Re: saaj - running out of ideas
          843834
          Ok, I realize you need some more info. Here is the prog.:

          import javax.xml.parsers.*;
          import javax.xml.soap.*;

          import org.xml.sax.*;

          import java.io.*;

          import org.w3c.dom.Document;

          import java.net.*;

          public class Testsoap {
          public static void main(String argv[]){

          Document document=null;

          MessageFactory msgFactory=null;
          SOAPMessage soapMessage=null;
          SOAPBody soapBody=null;
          SOAPConnectionFactory soapConnFactory=null;
          SOAPConnection soapConn=null;
          URL servicePoint= null;

          DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
          //factory.setValidating(true);
          //factory.setNamespaceAware(true);
          try {
          DocumentBuilder builder = factory.newDocumentBuilder();
          document = builder.parse( new File("xml.txt") );

          msgFactory = MessageFactory.newInstance();

          soapMessage = msgFactory.createMessage();

          soapBody = soapMessage.getSOAPBody();
          soapBody.addDocument(document);

          soapConnFactory = SOAPConnectionFactory.newInstance();
          soapConn = soapConnFactory.createConnection();

          servicePoint = new URL("http://v.europeiske.no/Services/EurowizSale.asmx");
          soapConn.call(soapMessage, servicePoint);

          }
          catch (SAXParseException spe) {
          // Error generated by the parser
          System.out.println("\n** Parsing error"
                    + ", line " + spe.getLineNumber()
                    + ", uri " + spe.getSystemId());
          System.out.println(" " + spe.getMessage() );

          // Use the contained exception, if any
          Exception x = spe;
          if (spe.getException() != null)
          x = spe.getException();
          x.printStackTrace();

          }
          catch (Exception e) {
          System.out.println(e);
          }
          } // main
          }

          CLASSPATH=/home3/java/lib/saaj/lib/saaj-api.jar:.

          Compiles just fine, but I get the following runtime error:
          javax.xml.soap.SOAPException: Unable to create message factory for SOAP: Provider com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl not found

          I expand my CLASSPATH to be:
          CLASSPATH=/home3/java/lib/saaj/lib/saaj-api.jar:.:/home3/java/lib/saaj/lib/saaj-impl.jar

          Now I get the following runtime error:
          Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/internet/ParseException
               at java.lang.Class.getDeclaredConstructors0(Native Method)
               at java.lang.Class.privateGetDeclaredConstructors(Class.java:1610)
               at java.lang.Class.getConstructor0(Class.java:1922)
               at java.lang.Class.newInstance0(Class.java:278)
               at java.lang.Class.newInstance(Class.java:261)
               at javax.xml.soap.FactoryFinder.newInstance(Unknown Source)
               at javax.xml.soap.FactoryFinder.find(Unknown Source)
               at javax.xml.soap.MessageFactory.newInstance(Unknown Source)
               at Testsoap.main(Testsoap.java:31)

          Well, I dont give up. I download JavaMail and extend my CLASSPATH again which by now looks like:
          CLASSPATH=/home3/java/lib/saaj/lib/saaj-api.jar:.:/home3/java/lib/saaj/lib/saaj-impl.jar:/home3/java/lib/mailapi.jar

          Another runtime error stops the show:

          Exception in thread "main" java.lang.NoClassDefFoundError: javax/activation/DataSource
               at com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl.createMessage(SOAPMessageFactory1_1Impl.java:27)
               at Testsoap.main(Testsoap.java:33)

          And now I give up..............

          Can someone please tell me what API's to use??

          Thanks in advance
          Tr0nd
          • 2. Re: saaj - running out of ideas
            843834
            This is the classpath I used for my stand-alone web service client. There might be some extras in there but they don't seem to do any harm:

                 jwsdp-1.5/saaj/lib/saaj-impl.jar
                 jwsdp-1.5/saaj/lib/saaj-api.jar
                 jwsdp-1.5/jwsdp-shared/lib/mail.jar
                 jwsdp-1.5/jwsdp-shared/lib/xsdlib.jar
                 jwsdp-1.5/jwsdp-shared/lib/commons-beanutils.jar
                 jwsdp-1.5/jwsdp-shared/lib/commons-collections.jar
                 jwsdp-1.5/jwsdp-shared/lib/commons-digester.jar
                 jwsdp-1.5/jwsdp-shared/lib/commons-logging.jar
                 jwsdp-1.5/jwsdp-shared/lib/jaas.jar
            jwsdp-1.5/jwsdp-shared/lib/jax-qname.jar
                 jwsdp-1.5/jwsdp-shared/lib/jta-spec1_0_1.jar
                 jwsdp-1.5/jwsdp-shared/lib/namespace.jar"
                 jwsdp-1.5/jwsdp-shared/lib/PackageFormat.jar
                 jwsdp-1.5/jwsdp-shared/lib/relaxngDatatype.jar
                 jwsdp-1.5/jwsdp-shared/lib/activation.jar