A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Java
»
Web Services
Author
Problem in web service client while trying to consume a service exposed on the net
Prasad Shindikar
Ranch Hand
Joined: Feb 18, 2007
Posts: 114
posted
Oct 18, 2008 08:19:00
0
this is the link for the WSDL file of an exposed web service on the internet.
http://www.freewebs.com/jimmy_cheng/CurrencyExchangeService.wsdl
I have tried to write a
java
web service client for the same.
However, the code gives an error.
The error stack is as shown below.
I am using Eclipse Europa, JDK 1.5
Exception in thread "main" java.lang.reflect.UndeclaredThrowableException at $Proxy0.getRate(Unknown Source) at com.client.CurrencyClient.main(CurrencyClient.java:28)Caused by: java.rmi.RemoteException: Call invocation failed; nested exception is: java.io.IOException: Could not transmit messageat org.jboss.ws.core.jaxrpc.client.CallImpl.invokeInternal(CallImpl.java:536) at org.jboss.ws.core.jaxrpc.client.CallImpl.invoke(CallImpl.java:277) at org.jboss.ws.core.jaxrpc.client.PortProxy.invoke(PortProxy.java:151) ... 2 moreCaused by: java.io.IOException: Could not transmit message at org.jboss.ws.core.client.RemotingConnectionImpl.invoke(RemotingConnectionImpl.java:204) at org.jboss.ws.core.client.SOAPRemotingConnection.invoke(SOAPRemotingConnection.java:77) at org.jboss.ws.core.CommonClient.invoke(CommonClient.java:337) at org.jboss.ws.core.jaxrpc.client.CallImpl.invokeInternal(CallImpl.java:517)... 4 moreCaused by: org.jboss.remoting.CannotConnectException: Can not connect http client invoker. at org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HTTPClientInvoker.java:333) at org.jboss.remoting.transport.http.HTTPClientInvoker.transport(HTTPClientInvoker.java:135) at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:122) at org.jboss.remoting.Client.invoke(Client.java:1634)at org.jboss.remoting.Client.invoke(Client.java:548) at org.jboss.ws.core.client.RemotingConnectionImpl.invoke(RemotingConnectionImpl.java:183)... 7 moreCaused by: org.jboss.ws.WSException: Invalid HTTP server response [404] - Not Found at org.jboss.ws.core.soap.SOAPMessageUnMarshaller.read(SOAPMessageUnMarshaller.java:77) at org.jboss.remoting.transport.http.HTTPClientInvoker.readResponse(HTTPClientInvoker.java:473) at org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HTTPClientInvoker.java:305) ... 12 more
The code for my client is :
package com.client; import java.net.URL;import java.util.Properties; import javax.xml.namespace.QName; import javax.xml.rpc.Service; import javax.xml.rpc.ServiceFactory; public class CurrencyClient { public static void main(String[] args) throws Exception { /*To access the internet, through the firewalls, we need specific proxy addresses*/ /*Properties sysProps = System.getProperties(); sysProps.put("proxySet", ""); sysProps.put("proxyHost", ""); sysProps.put("proxyPort", ""); */ URL url = new URL("http://www.freewebs.com/jimmy_cheng/CurrencyExchangeService.wsdl"); QName qname = new QName("http://www.xmethods.net/sd/CurrencyExchangeService.wsdl","CurrencyExchangeService"); System.out.println("Creating a service Using: \n\t" + url + " \n\tand " + qname); ServiceFactory factory = ServiceFactory.newInstance(); Service remote = factory.createService(url, qname); System.out.println("Obtaining reference to a proxy object"); CurrencyExchangePortType proxy = (CurrencyExchangePortType) remote.getPort(CurrencyExchangePortType.class); System.out.println("Accessed local proxy: " + proxy); float exchangeRate = proxy.getRate("USA", "EUR"); System.out.println("Exchange Rates between US and India: " + exchangeRate); }}
The webservice interface that i defined:
package com.client; import java.rmi.Remote; public interface CurrencyExchangePortType extends Remote{public float getRate(String country1, String country2);}
[ October 19, 2008: Message edited by: Balaji Loganathan ]
Vinod K Singh
Ranch Hand
Joined: Sep 30, 2008
Posts: 198
posted
Oct 19, 2008 00:16:00
0
Can you make code more readable?
My Blog
Prasad Shindikar
Ranch Hand
Joined: Feb 18, 2007
Posts: 114
posted
Oct 19, 2008 22:47:00
0
Hopefully this is more readable !
this is the link for the WSDL file of an exposed web service on the internet.
http://www.freewebs.com/jimmy_cheng/CurrencyExchangeService.wsdl
I have tried to write a java web service client for the same.
However, the code gives an error.
The error stack is as shown below.
Exception in thread "main" java.lang.reflect.UndeclaredThrowableException at $Proxy0.getRate(Unknown Source) at com.client.CurrencyClient.main(CurrencyClient.java:28) Caused by: java.rmi.RemoteException: Call invocation failed; nested exception is: java.io.IOException: Could not transmit message at org.jboss.ws.core.jaxrpc.client.CallImpl.invokeInternal(CallImpl.java:536) at org.jboss.ws.core.jaxrpc.client.CallImpl.invoke(CallImpl.java:277) at org.jboss.ws.core.jaxrpc.client.PortProxy.invoke(PortProxy.java:151) ... 2 more Caused by: java.io.IOException: Could not transmit message at org.jboss.ws.core.client.RemotingConnectionImpl.invoke(RemotingConnectionImpl.java:204) at org.jboss.ws.core.client.SOAPRemotingConnection.invoke(SOAPRemotingConnection.java:77) at org.jboss.ws.core.CommonClient.invoke(CommonClient.java:337) at org.jboss.ws.core.jaxrpc.client.CallImpl.invokeInternal(CallImpl.java:517) ... 4 more Caused by: org.jboss.remoting.CannotConnectException: Can not connect http client invoker. at org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HTTPClientInvoker.java:333) at org.jboss.remoting.transport.http.HTTPClientInvoker.transport(HTTPClientInvoker.java:135) at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:122) at org.jboss.remoting.Client.invoke(Client.java:1634) at org.jboss.remoting.Client.invoke(Client.java:548) at org.jboss.ws.core.client.RemotingConnectionImpl.invoke(RemotingConnectionImpl.java:183) ... 7 more Caused by: org.jboss.ws.WSException: Invalid HTTP server response [404] - Not Found at org.jboss.ws.core.soap.SOAPMessageUnMarshaller.read(SOAPMessageUnMarshaller.java:77) at org.jboss.remoting.transport.http.HTTPClientInvoker.readResponse(HTTPClientInvoker.java:473) at org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HTTPClientInvoker.java:305) ... 12 more
Client Code :
public static void main(String[] args) throws Exception { URL url = new URL("http://www.freewebs.com/jimmy_cheng/CurrencyExchangeService.wsdl"); QName qname = new QName("http://www.xmethods.net/sd/CurrencyExchangeService.wsdl","CurrencyExchangeService"); System.out.println("Creating a service Using: \n\t" + url + " \n\tand " + qname); ServiceFactory factory = ServiceFactory.newInstance(); Service remote = factory.createService(url, qname); System.out.println("Obtaining reference to a proxy object"); CurrencyExchangePortType proxy = (CurrencyExchangePortType) remote.getPort(CurrencyExchangePortType.class); System.out.println("Accessed local proxy: " + proxy); float exchangeRate = proxy.getRate("USA", "EUR"); System.out.println("Exchange Rates between US and India: " + exchangeRate); }
The interface that I have defined from the wsdl file :
package com.client; import java.rmi.Remote; public interface CurrencyExchangePortType extends Remote{ public float getRate(String country1, String country2); }
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12271
1
posted
Oct 20, 2008 03:52:00
0
caused by: org.jboss.ws.WSException: Invalid HTTP server response [404] - Not Found
This indicates your request addressing is not getting through to the server side application.
If this was my problem I would start by using SOAPui or TCPMON to capture the exact request text.
Bill
Java Resources at
www.wbrogden.com
I agree. Here's the link:
http://aspose.com/file-tools
subject: Problem in web service client while trying to consume a service exposed on the net
Similar Threads
conflict Jboss+WebLogic web service
"setProperty must be overridden by all subclasses of SOAPMessage" error
java.lang.reflect.UndeclaredThrowableException in JBOSS with EJB 3 as a web service
Problem in web service client while trying to consume a service exposed on the net
Exception: java.rmi.RemoteException: Call invocation failed;
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter