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 Unable to test webservice using a client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Unable to test webservice using a client" Watch "Unable to test webservice using a client" New topic
Author

Unable to test webservice using a client

Parijat Mukherjee
Greenhorn

Joined: Sep 21, 2003
Posts: 26
Hi ,

I am using tomcat version 5 and Axis 1_2RC2 .I have successfully deployed the web service http://localhost:8080/axis/helloWorld.jws .But i am unable to test the service .I have written a client code as follows :
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.utils.Options;

import javax.xml.rpc.ParameterMode;

public class CalcClient
{
public static void main(String[] args) throws Exception
{



String endpoint = "http://localhost:8080/axis/HelloServer.jws";





String method = "sayHelloTo";



Service service = new Service();
Call call = (Call) service.createCall();

call.setTargetEndpointAddress( new java.net.URL(endpoint) );
call.setOperationName( method );
call.addParameter( "op1", XMLType.XSD_STRING, ParameterMode.IN );
call.setReturnType( XMLType.XSD_STRING );
String ret = (String)call.invoke("","sayHelloTo",new Object [] {args[0]});
System.out.println(ret);
}
}

But when I try to execute this I am getting the following exceptions :

- Unable to find required classes (javax.activation.DataHandler and javax.mail.i
nternet.MimeMultipart). Attachment support is disabled.
Exception in thread "main" AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.net.ConnectException: Connection refused: connect
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:java.net.ConnectException: Conne
ction refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
ketFactory.java:138)
at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
ketFactory.java:99)
at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:1
31)
at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.ja
va:370)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:88)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg
y.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:147)
at org.apache.axis.client.Call.invokeEngine(Call.java:2719)
at org.apache.axis.client.Call.invoke(Call.java:2702)
at org.apache.axis.client.Call.invoke(Call.java:2378)
at org.apache.axis.client.Call.invoke(Call.java:2301)
at CalcClient.main(CalcClient.java:32)

{http://xml.apache.org/axis/}hostname:BCD-DDTQ

java.net.ConnectException: Connection refused: connect
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
ketFactory.java:138)
at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSoc
ketFactory.java:99)
at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:1
31)
at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.ja
va:370)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:88)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrateg
y.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:147)
at org.apache.axis.client.Call.invokeEngine(Call.java:2719)
at org.apache.axis.client.Call.invoke(Call.java:2702)
at org.apache.axis.client.Call.invoke(Call.java:2378)
at org.apache.axis.client.Call.invoke(Call.java:2301)
at CalcClient.main(CalcClient.java:32)

Can some please help as I am a newcomer to the web services .
Thanks
Parijat
Rr Kumaran
Ranch Hand

Joined: Sep 17, 2001
Posts: 548
connection refused exception will come when u r behind a firewall and other proxy related issues. if so try below code in your client program:

System.setProperty("http.proxyHost", "<your proxy ip>");
System.setProperty("http.proxyPort", "<your proxy port>");


RR Kumaran
SCJP 1.4
Parijat Mukherjee
Greenhorn

Joined: Sep 21, 2003
Posts: 26
Thanks Priya ,

But I am not behind any firewall or proxy .Again the error saying "- Unable to find required classes (javax.activation.DataHandler and javax.mail.i
nternet.MimeMultipart)." is not understood as I have already set the classpath for activation.jar and mail.jar which has the above mentioned classes .
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Originally posted by Parijat Mukherjee:
Hi ,
I am using tomcat version 5 and Axis 1_2RC2 .I have successfully deployed the web service http://localhost:8080/axis/helloWorld.jws .But i am unable to test the service .


Can you see the wsdl file by using http://localhost:8080/axis/helloWorld.jws?wsdl ??


Spritle Software Blogs
Ganesh Baviskar
Greenhorn

Joined: Nov 03, 2003
Posts: 1
Hi Parijat,

You must start your Tomcat before running the AdminClient through java command.
As that class has a URL as command line argument http://localhost:8080/axis/services/AdminService
so the client needs to connect to the servlet.

Also, just for additional information, the command is,

java -classpath .;%CLASSPATH% org.apache.axis.client.AdminClient <.wsdd file path> -l http://localhost:8080/axis/services/AdminService

Best of luck !!!

Regards,
Ganesh A. Baviskar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to test webservice using a client