2.利用CFX开发Web Service的客户端:解释由wsdl2java生成的其中一些类

1.org.fkjava.cfx.ws.HelloWorld,接口,存根是远端服务器的代理,所以远端服务器和存根都要实现共同的

接口,此接口即是org.fkjava.cfx.ws.HelloWorld

package org.fkjava.cfx.ws;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;

/**
 * This class was generated by Apache CXF 2.2.2
 * Thu Jul 19 15:54:40 CST 2012
 * Generated source version: 2.2.2
 * 存根是远端服务器的代理,所以远端服务器和存根都要实现共同的
 * 接口,此接口即是org.fkjava.cfx.ws.HelloWorld 
 */
 
@WebService(targetNamespace = "http://ws.cfx.fkjava.org/", name = "HelloWorld")
@XmlSeeAlso({ObjectFactory.class})
public interface HelloWorld {

    @WebResult(name = "return", targetNamespace = "")
    @RequestWrapper(localName = "sayHi", targetNamespace = "http://ws.cfx.fkjava.org/", className = "org.fkjava.cfx.ws.SayHi")
    @ResponseWrapper(localName = "sayHiResponse", targetNamespace = "http://ws.cfx.fkjava.org/", className = "org.fkjava.cfx.ws.SayHiResponse")
    @WebMethod
    public java.lang.String sayHi(
        @WebParam(name = "arg0", targetNamespace = "")
        java.lang.String arg0
    );
}


2.(不是由wsdl2java生成的)javax.xml.ws.Service这个接口能够得到远端服务器的代理,即是能得到存根


3.org.fkjava.cfx.ws.impl.HelloWorldWs实现接口javax.xml.ws.Service

/*
 * 
 */

package org.fkjava.cfx.ws.impl;

import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.Service;
import org.fkjava.cfx.ws.HelloWorld;

/**
 * This class was generated by Apache CXF 2.2.2
 * Thu Jul 19 15:54:40 CST 2012
 * Generated source version: 2.2.2
 * 实现接口javax.xml.ws.Service(这个接口能够得到远端服务器的代理,即是能得到存根)
 */


@WebServiceClient(name = "HelloWorldWs", 
                  wsdlLocation = "http://192.168.1.2/HelloWorld?WSDL",
                  targetNamespace = "http://impl.ws.cfx.fkjava.org/") 
public class HelloWorldWs extends Service {

    public final static URL WSDL_LOCATION;
    public final static QName SERVICE = new QName("http://impl.ws.cfx.fkjava.org/", "HelloWorldWs");
    public final static QName HelloWorldWsPort = new QName("http://impl.ws.cfx.fkjava.org/", "HelloWorldWsPort");
    static {
        URL url = null;
        try {
            url = new URL("http://192.168.1.2/HelloWorld?WSDL");
        } catch (MalformedURLException e) {
            System.err.println("Can not initialize the default wsdl from http://192.168.1.2/HelloWorld?WSDL");
            // e.printStackTrace();
        }
        WSDL_LOCATION = url;
    }

    public HelloWorldWs(URL wsdlLocation) {
        super(wsdlLocation, SERVICE);
    }

    public HelloWorldWs(URL wsdlLocation, QName serviceName) {
        super(wsdlLocation, serviceName);
    }

    public HelloWorldWs() {
        super(WSDL_LOCATION, SERVICE);
    }

    /**
     * 
     * @return
     *     returns HelloWorld
     */
    @WebEndpoint(name = "HelloWorldWsPort")
    public HelloWorld getHelloWorldWsPort() {
        return super.getPort(HelloWorldWsPort, HelloWorld.class);
    }

    /**
     * 
     * @param features
     *     A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.  Supported features not in the <code>features</code> parameter will have their default values.
     * @return
     *     returns HelloWorld
     */
    @WebEndpoint(name = "HelloWorldWsPort")
    public HelloWorld getHelloWorldWsPort(WebServiceFeature... features) {
        return super.getPort(HelloWorldWsPort, HelloWorld.class, features);
    }

}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值