Hello,
Here is the example I have tried for you and hope it can solve your
problem.
There are two .class files (TemperatureServiceIntf.class and
TemperatureClient.class).
Please check this out...
And The Below is the result I get from the web service published you
mentioned in your last email.
************************************************************************
*********************
D:\tem>ls
TemperatureClient.class TemperatureServiceIntf.class
TemperatureClient.java TemperatureServiceIntf.java
TemperatureClient.java.bak
D:\tem>java -classpath .;%axislib% TemperatureClient
This example shows how to create a dynamic client application that
invokes a Web
service.
The webservice used was:
http://www.xmethods.net/sd/TemperatureService.wsdl
The temperature for 19010 is:
The Result Returned By The Web Service is: 13.0
--- The End ---
************************************************************************
*************************
Don't need to worry about the variable %axislib% ...
It just contains all needed classpaths in order for me to compile and
run this program.
The TemperatureServiceIntf.java is listed below:
import java.rmi.*;
public interface TemperatureServiceIntf extends java.rmi.Remote {
public float getTemp(String zipcode) throws
java.rmi.RemoteException;
}
************************************************************************
*************************
The TemperatureClient.java is listed below:
import javax.xml.namespace.QName;
import javax.xml.rpc.*;
import java.net.*;
public class TemperatureClient {
public static void main(String[] args) {
try {
ServiceFactory factory = ServiceFactory.newInstance();
String targetNamespace =
"
http://www.xmethods.net/sd/TemperatureService.wsdl";
String wsdlURL =
"
http://www.xmethods.net/sd/TemperatureService.wsdl";
QName serviceName = new QName(targetNamespace,
"TemperatureService");
QName portName = new QName(targetNamespace,
"TemperaturePort");
Service tempService = factory.createService(new
URL(wsdlURL), serviceName);
TemperatureServiceIntf tempServiceIntf =
(TemperatureServiceIntf)tempService.getPort(portName,
TemperatureServiceIntf.class);
float result = tempServiceIntf.getTemp("19010");
System.out.println("\n");
System.out.println("This example shows how to create a
dynamic " +
"client application that invokes a Web
service.");
System.out.println("The webservice used was: " +
"
http://www.xmethods.net/sd/TemperatureService.wsdl");
System.out.println("The temperature for 19010 is: ");
System.out.println("The Result Returned By The Web
Service is: " + result);
System.out.println("--- The End ---");
} catch(Exception e) {
System.err.println("Error Occured: Check Exception: " +
e.getMessage());
}
}
}
************************************************************************
*************************
Have a Wonderful Day. Wish you all Good!
Jay
************************************************************************
*************************
-----Original Message-----
From: Public discussion on JAX-RPC [mailto:JAXRPC-INTEREST_at_JAVA.SUN.COM]
On Behalf Of Sauquet Dominique
Sent: Friday, January 24, 2003 2:15 AM
To: JAXRPC-INTEREST_at_JAVA.SUN.COM
Subject: Writing a dynamic Proxy Client
Hi
I am a newbie in the list (and also in WSDP)
I have followed the step to create a Dynamic Proxy example following the
Hello example.
It runs fine.
Now, I would like to access a public Web Service and I am having a lot
of
trouble.
(sorry if the question seems dumb but I really need help !!)
I have tried several examples :
//=== create service factory
ServiceFactory factory = ServiceFactory.newInstance();
//=== define qnames
String targetNamespace =
"
http://www.xmethods.net/sd/TemperatureService.wsdl";
QName serviceName = new QName(targetNamespace,
"TemperatureService");
QName portName = new QName(targetNamespace,
"TemperaturePort");
QName operationName = new QName("urn:xmethods-Temperature",
"getTemp");
URL wsdlLocation = new
URL("
http://www.xmethods.net/sd/TemperatureService.wsdl");
System.setProperty("proxyHost","secureproxy.prosodie");
System.setProperty("proxyPort","8080");
//=== create service
Service service = factory.createService(wsdlLocation,
serviceName);
//=== create call
Call call = service.createCall(portName, operationName);
//=== invoke the remote web service
Float result = (Float) call.invoke(new Object[] {"19010"});
System.out.println("\n");
System.out.println("This example shows how to create a dynamic
client application that invokes a Web service.");
System.out.println("The webservice used was: " +
"
http://www.xmethods.net/sd/TemperatureService.wsdl");
System.out.println("The temperature for 19010 is: ");
System.out.println(result);
and I get an error with float
I tried :
//=== create service factory
ServiceFactory factory = ServiceFactory.newInstance();
//=== define qnames
String targetNamespace = "
http://www.themindelectric.com/"
+
"wsdl/net.xmethods.services.stockquote.StockQuote/";
QName serviceName = new QName(targetNamespace,
"net.xmethods.services.stockquote.StockQuoteService");
QName portName = new QName(targetNamespace,
"net.xmethods.services.stockquote.StockQuotePort");
QName operationName = new QName("urn:xmethods-delayed-quotes",
"getQuote");
URL wsdlLocation = new
URL("
http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl"
);
System.setProperty("proxyHost","secureproxy.prosodie");
System.setProperty("proxyPort","8080");
//=== create service
Service service = factory.createService(wsdlLocation,
serviceName);
//=== create call
Call call = service.createCall(portName, operationName);
//=== invoke the remote web service
Float result = (Float) call.invoke(new Object[] {"BEAS"});
System.out.println("\n");
System.out.println("This example shows how to create a dynamic
client application that invokes a Web service.");
System.out.println("The webservice used was: " +
"
http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl");
System.out.println("The quote for BEAS is: ");
System.out.println(result);
and I get an error with invoke
What I am doing wrong ?
Could anyone send me :
- an example that works ?
- the way to compile ? (Do I follow the same procedure
ant build
ant deploy
ant build-dynamic
when I only develop the client part)
Thanks a lot
Dominique
> _________________________
> Dominique Sauquet
> dsauquet_at_prosodie.com
> Direction des Nouveaux Produits
> PROSODIE
> 150 Rue Galli?ni
> 92100 Boulogne Billancourt
>
> Tel : 01 46 84 13 12
> http://www.prosodie.com
> ____________________________
>