users@jax-rpc.java.net

Re: Writing a dynamic Proxy Client

From: Jay Chen <jay_at_TERA-ASPER.COM>
Date: Mon, 27 Jan 2003 14:18:04 +0800

Hi, Dominique,
The web service, named "Temperature Services", you have been testing so
far, seems not available currently... I also got the errors while
running my program to invoke that service... last week, I was able to
invoke it and got the result as desired. I implemented three different
ways to invoke it and it worked fine last week. However, today I tried
to run it and I got the following error. ...
************************************************************************
************************

D:\tmp\dproxy>java -cp .;%axislib% TemperatureClient
Error Occured: Check Exception: ; nested exception is:
        org.xml.sax.SAXParseException: Premature end of file.

************************************************************************
*************************

It is my first time to meet this kind of error and trying to solve it
now.. I will let you know while I get it done...

However, I also try to run the another web service published in the
xmthods.net..
The service name is " M$N Messenger User Status
".............
Good News, I got the happy result.......... it runs perfectly. This
service makes me enable to detect whether the specified hotmail user is
currently online or offline...

************************************************************************
*************************
The temperature service now is unavailable........................so
don?t use this service to
Test your web service program....

Plus...........For your last problem, I guess the reason of that you got
those errors is because you didn't specify all necessary classes or .jar
file in your java runtime's class path in order to run it.. ... the
problems you have encountered may have nothing to do with whether you
set the proxyHost and proxyPort into your system property or not...

"""""""""""""""
com.sun.xml.rpc.client.dii.CallInvocationHandler.doCall """""""""
and may I ask where you get this stuff... for rpc..I am using the
JAX-RPC
I didn't find out any class or package name starting like this.


Wish you all the best.

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