package interfax does not exist....

6 posts / 0 new
Last post
sinoea
Offline
Joined: 22 Nov 2005
package interfax does not exist....

Hi,
I am new to web services and have understood to use the axis.jar for
java web services.

I am using Tomcat 5.0 and J2SE 5.0 for trying the interfax api.
I am interested in using the interfax api but it doesn't work.

There is a simple tutorial provided in the axis file.
There I am trying to use the the interfax api.

So I have added Interfax.jar in the C:\Tomcat 5.0\webapps\axis\WEB-INF\lib directory.
I have also added the following method in the happyaxis.jsp file provided
as part of the axis file.

 /**
    * Test a fax print
    */
    public void printFax(){
           try {
    		long result;
    		// Create an instance of the Web Service Object
    		InterFaxSoapStub ifs = new InterFaxSoapStub(new URL("http://ws.interfax.net/DFS.asmx"),new Service(new QName("SendCharFax")));
    
    		// Invoke the SendCharFax method
    		result = ifs.sendCharFax("MyUserName","MyPassword","+442072112323","This is a sample fax from me","TXT");
    
    		if (result > 0)
   
       	        // Positive returned value indicates that the fax was sent successfully.
    	        // The return value is the Transaction ID.
    		System.out.println("Fax submitted properly. Transaction number: " + result);
    		else
    	       	   // Negative returned value indicates sending failure.
                   // See error code definitions
    		   System.out.println("Error sending fax!");
    		} catch (Exception e) {
    			System.out.println(e.toString());
           }
    }

On top of this jsp file the following classes/packages are imported.

<%@ page contentType="text/html; charset=utf-8"
         import="java.io.InputStream,
                 java.io.IOException,
                 javax.xml.parsers.SAXParser,
                 java.lang.reflect.*,
                 javax.xml.parsers.SAXParserFactory,
	 org.apache.axis.client.Service,
	 interfax.InterFaxSoapStub,
                 javax.xml.namespace.QName,
                 java.net.URL"
   session="false" %>

And then I have used the method (printFax()) as previously declared
somewhere in the jsp file.

Now the problem is that the Tomcat servlet engine doesn't find
the interfax.InterFaxSoapStub.
The Interfax.jar file is placed like this:
C:\Tomcat 5.0\webapps\axis\WEB-INF\lib\Interfax.jar

Now what is the problem?
Please help as I need to get it working urgently.

Thanks!

hernansilberman
Offline
Joined: 22 Nov 2005

Hey there, I'm guessing that you're using the Java sample from the InterFAX website (Interfax.jar).

I just looked into that jar file:

%jar -tf Interfax.jar
META-INF/
META-INF/MANIFEST.MF
ArrayOfFaxItem.class
ArrayOfFaxItemEx.class
FaxItem.class
FaxItemEx.class
InterFax.class
InterFaxLocator.class
InterFaxSoap.class
InterFaxSoapStub.class

... and there doesn't appear to be an interfax package for the classes in it. Try importing InterFaxSoapStub without the "interfax." package qualifier on it.

good luck...
hernan

sinoea
Offline
Joined: 22 Nov 2005

It still doesn't work.

This is very strange...

hernansilberman
Offline
Joined: 22 Nov 2005

Sounds like you've got lots of places where things could be going wrong. I think you should try to do the following:

If you haven't already, build a standalone Java test program that uses the Interfax.jar file to make the web service call you're trying to make from within your webapp. If you get this running outside of Tomcat, you will have assurance that the web service call is happening successfully. It will be much easier to debug having that basic standalone code worked out. A simple command-line only program will do.

Once you have that working (it should be a quick thing to do), you can worry about accessing it from your webapp. Your problem definitely sounds like a deployment issue if you're getting a ClassNotFoundException.

thnx..
hernan

sinoea
Offline
Joined: 22 Nov 2005

Ok it works as standalone, I mean the compilation.
But it says 'Error printing fax!'.

It could be the phone number.
It is to London and the number is 00442072267877.
The actual number from london is 02072267877, and the U.K extension
is 0044.

I have tried several ways but see no success.
Here is another example, +442072267877.

Could it be because the waiting persons fax is not working.

Here is the code...

import java.net.URL;
import org.apache.axis.client.*;
import javax.xml.namespace.QName;

public class TestFax {

	public TestFax(){}

    /**
    * Test a fax print
    */
    public static void printFax(){
           try {
                long result;
                // Create an instance of the Web Service Object
        	InterFaxSoapStub ifs = new InterFaxSoapStub(new URL("http://ws.interfax.net/DFS.asmx"),new Service(new QName("SendCharFax")));

        	// Invoke the SendCharFax method
        	result = ifs.sendCharFax("sinoea","code1840","00442072267877","This is a sample fax from sinoea","TXT");

        	if (result > 0)

           	// Positive returned value indicates that the fax was sent successfully.
        	// The return value is the Transaction ID.
                   System.out.println("Fax submitted properly. Transaction number: " + result);
        	else
                // Negative returned value indicates sending failure.
                // See error code definitions
                System.out.println("Error sending fax!");
        	} catch (Exception e) {
        	 	 System.out.println(e.toString());
           }
    }

    public static void main(String[] args){

     TestFax test = new TestFax();
     test.printFax();

	}

}

sinoea
Offline
Joined: 22 Nov 2005

It works now, I have used the classes provided with the O'Reilly book.

I am using Tomcat 4.1 and j2sdk1.4.0.
Just wondering if later versions can be used.

Thanks!

Login or register to post comments