wood burning stoves 2.0*
The moose likes Web Services and the fly likes Error when calling a web service in Java Client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Error when calling a web service in Java Client" Watch "Error when calling a web service in Java Client" New topic
Author

Error when calling a web service in Java Client

sravanthi yendluri
Greenhorn

Joined: May 25, 2008
Posts: 23
I have proxy server set up and accessible from my Windows server(I can access the web client), but when I call the web service from Java client I get this error in the Console.

run:
===========================================
Project Name is:Test Project
Logging into the Project...
In Try Block
Have an Exception
Feb 9, 2009 11:00:03 AM ttsample.Engine Login
SEVERE: null
java.rmi.RemoteException: HTTP transport error: java.net.UnknownHostException: http; nested exception is:
HTTP transport error: java.net.UnknownHostException: http
Logged in...
at ttsample.TtsoapcgiPortType_Stub.databaseLogon(TtsoapcgiPortType_Stub.java:819)
at ttsample.Engine.Login(Engine.java:74)
at ttsample.Main.main(Main.java:30)
Caused by: HTTP transport error: java.net.UnknownHostException: http
at com.sun.xml.rpc.client.http.HttpClientTransport.invoke(HttpClientTransport.java:140)
at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:96)
at ttsample.TtsoapcgiPortType_Stub.databaseLogon(TtsoapcgiPortType_Stub.java:802)
... 2 more
BUILD SUCCESSFUL (total time: 4 seconds)

I am consuming a WSDL to invoke a web operation in my program in NetBeans6.5 . I tried the -D option to set the Proxy host and port in the Project Properties Run option in VM Options as "-Dhttp.proxyHost=10.1.104.63 -Dhttp.proxyPort=8080"

Any help would be greatly appreciated.

Thanks,
Sravanthi.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41178
    
  45
How are you specifying the target URL? It looks as if the code considers "http" to be the target, which is missing the actual host name.


Ping & DNS - my free Android networking tools app
sravanthi yendluri
Greenhorn

Joined: May 25, 2008
Posts: 23
In the program I am not using any URL.

I am consuming a WSDL file using JAX-RPC in my program.

When I run my Main program I am getting the error. I used the same program with the Test Track server we use to see if its logging in or not and it worked.

When I am trying to connect to the test track server that I locally loaded on my system it is not working. So I configured Apache with my Test Track server and tested if the web client is working or not and found that it was working but when I am trying to connect to the web client through my program it is not working.

Is this a proxy settings error???When I tried to change the proxy settings and run the web client I was unable to access the web client.So I reset all of my settings back and then saw that it worked as before.

I set my proxy settings in the VM options in the properties of the project as

"-Dhttp.proxyHost=http://localhost -Dhttp.proxyPort=80"

and even tried
"-Dhttp.proxyHost=localhost -Dhttp.proxyPort=8080" but I was getting the same error.

Where am I going wrong???

This is the code that uses the web operation that I am calling using the WSDL that I am consuming:

package ttsample;
/**
*
* @author syendluri
*/
public class Engine {
//protected TtsoapcgiPortType _ttsoapcgi;
Ttsoapcgi ttsoapcgi = new Ttsoapcgi_Impl();
TtsoapcgiPortType _ttsoapcgi;
//= ttsoapcgi.getTtsoapcgi();

protected String ttProject = "Test Project";
protected long ttCookie = 0;
protected String ttUser;
protected String ttPassword;

public Engine()
{
ttProject = "Test Project";
long ttCookie = 0;
ttUser = "syendluri";
ttPassword = "******";

try
{
//the _ttsoapcgi is what we'll use to make all the calls
_ttsoapcgi = ttsoapcgi.getTtsoapcgi();
// System.out.println(_ttsoapcgi);
}
catch(javax.xml.rpc.ServiceException ex)
{
java.util.logging.Logger.getLogger(Ttsoapcgi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
}

public void SetProject(String strProject)
{
ttProject = strProject;
System.out.println("Project Name is:"+ttProject);
}

public String GetProject()
{
return ttProject;
}

public long GetCookie()
{
return ttCookie;

}

public boolean Login()
{
boolean result = false;
//First we need to build the project object for that we need to create the database object and set its name
CDatabase ttDatabase = new CDatabase();
ttDatabase.setName(ttProject);

//Now we can try to log in
try
{
// This code block invokes the Ttsoapcgi:databaseLogon operation on web service
System.out.println("In Try Block");

ttCookie = _ttsoapcgi.databaseLogon(ttProject, ttUser, ttPassword);
System.out.println("Session ID:"+ttCookie);

if (ttCookie > 0)
{
result = true;
}
}

catch(Exception ex)
{
System.out.println("Have an Exception");
java.util.logging.Logger.getLogger(Ttsoapcgi.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
return result;
}

public boolean Logout()
{
boolean result = false;
if (ttCookie > 0)
{
try
{
_ttsoapcgi.databaseLogoff(ttCookie);
result = true;
}
catch(java.rmi.RemoteException ex)
{
result = false;
}
}
return result;
}

}

I am getting the error on the databaseLogon() Method.

Thanks,
Sravanthi.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
sravanthi yendluri wrote:In the program I am not using any URL.

I am consuming a WSDL file using JAX-RPC in my program.


The URL is in the WSDL. The stub may have copied the URL or is still getting it from the WSDL.

Look for something like

The location attribute contains the endpoint reference.

How to Get Help with SOAP web services
sravanthi yendluri
Greenhorn

Joined: May 25, 2008
Posts: 23
This is the URL that I am accessing.

<service name="ttsoapcgi">
<documentation>gSOAP 2.7.8c generated service definition</documentation>
<port name="ttsoapcgi" binding="tns:ttsoapcgi">
<SOAP:address location="http://http://10.1.104.63/:80/TestTrack/ttsoapcgi.exe"/>
</port>
</service>

I tried to access the URL that is given in the SOAP address location but I got an error saying the requested URL is not found.

Actually under the htdocs of Apache I created a folder by name ttweb instead of TestTrack.So I tried accessing http://localhost/ttweb/ which worked but when I tried accessing http://localhost/ttweb/ttsoapcgi.exe/ I am getting an error that I dont have permission to access ttsoapcgi.exe on this server. Actually ttsoapcgi.exe is in the cgi-bin folder of Apache.

What are the further steps that I need to follow to access the web page from my program??

Thanks,
Sravanthi.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Apache Tutorial: Dynamic Content with CGI
sravanthi yendluri
Greenhorn

Joined: May 25, 2008
Posts: 23
Hello Peer,

Thank You for the link but,I configured Apache to work with the server already with all the specifications given in the link that you provided me and I am able to log onto the web client.

My problem is I am trying to access the web client through my Java program and I am getting the "HTTP Status-Code 404:Not Found" error.

Can you guide me how I can get through this error?

Thanks,
Sravanthi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error when calling a web service in Java Client
 
Similar Threads
Generated Stub and Proxy Settings !!
Trying to Develop Web Services Client.
Unable to tcpmon remote web services
Working with Internet URL from Eclipse
How can I configure the HTTP proxy for a Web Service client running in JBoss 4?