users@jax-rpc.java.net

Re: Writing a dynamic Proxy Client

From: Jay Chen <jay_at_TERA-ASPER.COM>
Date: Mon, 27 Jan 2003 11:26:49 +0800

Hi, Dominique,
Sorry for replying your email so late since I haven't checked my mails
this weekend...sorry for that.. !
Um, I have tried those two .java files, compiled them and tried to run
in my computer...
Good News is that It works fine in the environment of my computer.

First time, I used the original codes you provides.
System.setProperty("proxyHost","secureproxy.prosodie");
System.setProperty("proxyPort","8080");

It works fine.. and I got the following output. ..
************************************************************************
************************
This example shows how to create a dynamic client application that
invokes a Web
 service.
The webservice used was:
http://services.xmethods.net/soap/urn:xmethods-delayed-
quotes.wsdl
The quote for is:
18.78
************************************************************************
*************************
and then, I tried to modify the codes by changing them as like the
below;

System.setProperty("proxyHost","localhost");
System.setProperty("proxyPort","8080");

Fortunately, I got the same output. It also works very well...

Now I am trying to figure out why you would get those exceptions.
As soon as I got it.. I will drop you an email.. ....
...
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 7:17 PM
To: JAXRPC-INTEREST_at_JAVA.SUN.COM
Subject: Re: Writing a dynamic Proxy Client

Thank you Jay
Unfortunately, it still does not work !!!
I compiled your code, just adding as the 2 lines at the top of my main :
        System.setProperty("proxyHost","...");
        System.setProperty("proxyPort","8080");
and I get the following exception :
  modeler error: model error: invalid entity name: "float" (in
namespace:
"http://www.w3.org/1999/XMLSchema")
while excecuting ;
  Service tempService = factory.createService(new URL(wsdlURL),
serviceName);

which is the same error I previously got with my code.

I tried another example. This one fails with
java.rmi.ServerException: electric.directory.DirectoryException: cannot
automati
cally create subdirectory http:
        at
com.sun.xml.rpc.client.StreamingSender._raiseFault(StreamingSender.ja
va:357)
        at
com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:228
)
        at
com.sun.xml.rpc.client.dii.CallInvokerImpl.doInvoke(CallInvokerImpl.j
ava:54)
        at
com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:279)
        at
com.sun.xml.rpc.client.dii.CallInvocationHandler.doCall(CallInvocatio
nHandler.java:96)
        at
com.sun.xml.rpc.client.dii.CallInvocationHandler.invoke(CallInvocatio
nHandler.java:68)
        at $Proxy0.getQuote(Unknown Source)
        at StockClient.main(StockClient.java:37)
What did I do wrong ??
thanks again
        Dominique


-----Message d'origine-----
De : Jay Chen [mailto:jay_at_TERA-ASPER.COM]
Envoyé : vendredi 24 janvier 2003 06:20
À : JAXRPC-INTEREST_at_JAVA.SUN.COM
Objet : Re: Writing a dynamic Proxy Client


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
> ____________________________
>