logpersonwebserviceclientnospring.java

来自「《精通Spring》源代码」· Java 代码 · 共 60 行

JAVA
60
字号
/*
 * Created on 2005-2-10
 * 
 * http://www.open-v.com 提供代码的维护工作
 */
package com.openv.spring;

import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.RemoteException;

import javax.xml.namespace.QName;
import javax.xml.rpc.Service;
import javax.xml.rpc.ServiceException;
import javax.xml.rpc.ServiceFactory;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * LogPersonWebServiceClientNoSpring客户应用
 * 
 * @author luoshifei
 */
public class LogPersonWebServiceClientNoSpring {
    private static final Log log = LogFactory
            .getLog(LogPersonWebServiceClientNoSpring.class);

    public static void main(String[] args) {
        String wsdlDocumentUrl = 
            "http://localhost:8080/example28/axis/LogPerson?wsdl";
        String namespaceUri = 
            "http://localhost:8080/example28/axis/LogPerson";
        String serviceName = "JaxRpcLogPersonServiceService";
        String portName = "LogPerson";

        QName serviceQN = new QName(namespaceUri, serviceName);
        QName portQN = new QName(namespaceUri, portName);

        try {
            
            ServiceFactory sf = ServiceFactory.newInstance();
            Service service = sf.createService(new URL(wsdlDocumentUrl),
                    serviceQN);

            RemoteILogPerson iLogPerson = (RemoteILogPerson) service.getPort(
                    portQN, RemoteILogPerson.class);
            
            log.info(iLogPerson.getPerson("Shifei,Luo"));
            
        } catch (ServiceException se) {
            log.error("ServiceException异常", se);
        } catch (MalformedURLException mu) {
            log.error("MalformedURLException异常", mu);
        } catch (RemoteException re) {
            log.error("RemoteException异常", re);
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?