开发者

Web-service from a java Desktop-application

I'am trying to use web-service from a desktop-application I used the Tutorials in here and made this code to connect to开发者_Python百科 the web-service server project

public static void main(String[] args) {

    float f1 = 60.5F;
    float c1 = 0;
    ConverterProxy s = new ConverterProxy();

    try {
        c1 = s.farenheitToCelsius(f1);
    } catch (RemoteException e) {
        e.printStackTrace();
    }

    System.out.println("Output: " + c1);

}

it did work put I need some where that explain what the other client side classes do

i need to know what the classes

Converter,ConverterProxy,ConverterService,ConverterServiceLocator,ConverterSoapBindingStub

Do and what we need them for ?

Thanks in advance


It's a bit of a guess, as I'm not using your tutorial, but a lot of these classes follow a similar pattern.

Converter is likely an interface, which defines what methods the service will offer.

ConverterProxy is likely the client-side exposure of the Converter interface. It doesn't actually do the work, instead it takes the methods in Converter and packages them for network transport.

ConverterService is likely the server-side exposure of the Converter interface. It takes network packages from ConverterProxy calls, unpacks them, performs the conversion, and sends the reply back to the ConverterProxy at the other end of the network connection. ConverterProxy will then unpack the network message, take out the result, and return it as the answer.

ConverterServiceLocator is likely a class which concerns itself with the code necessary to find a ConverterService. Sometimes to maintain a degree of flexibility, the ConverterService's location is not specified at compile time, and ConverterServices tell a central registry (typically UDDI) where they are when they start up. ConverterServiceLocator will then (as you attempt to bind to a ConverterService with a ConverterProxy) query the central registry, and provide either the location of a suitable ConverterService or provide the ConverterService directly (I can't remember if it does the fetching of the Service for you).

ConverterSoapBindingStub is a class that provides the (otherwise hidden) Java to SOAP XML marshalling / demarshalling necessary for the translation of ConverterProxy requests to get turned into XML requests and ConverterProxy replies to get turned into XML replies.

Again, I don't have access to your source code or your tutorial (and I don't have time to look over it at the moment); but, these are educated guesses based on very common naming conventions.


You can look through the code but it's a bit cryptic. The main thing is that you are generated a class that wraps the web service as a Java object. The operations of the service then become methods in this class. You can use that to interact with the web service as you have found.

The rest of the classes handle the plumbing between that Java class and the web service. They convert the parameters you supply into a SOAP (XML dialect) request, send it to the web service and they also receive the SOAP response and convert it back to data your Java program can understand.

Just like the first generated class with the method/operations wraps the web service behaviour, the other classes wrap the plumbing/communication protocol used to call the web service.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜