Save This Page
Home » jaxb-2_1_7 » org » acme » [javadoc | source]
    1   /**
    2    *
    3    * Copyright 2003-2004 The Apache Software Foundation
    4    *
    5    *  Licensed under the Apache License, Version 2.0 (the "License");
    6    *  you may not use this file except in compliance with the License.
    7    *  You may obtain a copy of the License at
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    *  Unless required by applicable law or agreed to in writing, software
   12    *  distributed under the License is distributed on an "AS IS" BASIS,
   13    *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    *  See the License for the specific language governing permissions and
   15    *  limitations under the License.
   16    */
   17   package org.acme;
   18   
   19   import java.net.URL;
   20   import javax.xml.namespace.QName;
   21   import javax.xml.rpc.Service;
   22   import javax.xml.rpc.ServiceFactory;
   23   
   24   public class MagicGBallJaxRpcClient {
   25       public static void main(String[] args) {
   26           if (args.length < 1) {
   27               System.err.println("Please ask a question");
   28               System.exit(-1);
   29           }
   30   
   31           try {
   32               URL wsdlURL = new URL("http://localhost:8000/services/MagicGBall?wsdl");
   33               String namespaceURI = "http://acme.org/magicGball";
   34               QName serviceQName = new QName(namespaceURI, "MagicGBallService");
   35               QName portQName = new QName(namespaceURI, "MagicGBallPort");
   36   
   37               ServiceFactory serviceFactory = ServiceFactory.newInstance();
   38               Service service = serviceFactory.createService(wsdlURL, serviceQName);
   39               MagicGBallEndpoint mGball = (MagicGBallEndpoint) service.getPort(portQName, MagicGBallEndpoint.class);
   40   
   41               for (int i = 0; i < args.length; i++) {
   42                   String question = args[i];
   43                   String answer = mGball.ask(question);
   44                   System.out.println(answer);
   45               }
   46           } catch (Exception e) {
   47               System.err.println(e.toString());
   48           }
   49       }
   50   }

Save This Page
Home » jaxb-2_1_7 » org » acme » [javadoc | source]