石头0001 2013-07-23 12:40
浏览 2061

xfire 客户端调用出错,求高人指点

根据wsdl用myeclipse 生成的客户端,这个类为什么报错,后面的这些代码什么意思,求高人指点

props.put("annotations.allow.interface", true);
AnnotationServiceFactory asf = new AnnotationServiceFactory(
new Jsr181WebAnnotations(), tm, new AegisBindingProvider(
new JaxbTypeRegistry()));
asf.setBindingCreationEnabled(false);
service0 = asf.create((com.zlkj.drvschool.webservice.jjzdvpnservicePortType.class),props);
{
AbstractSoapBinding soapBinding = asf.createSoap11Binding(service0,
new QName("http://vpnservice.webservice.zlkj.com",
"jjzdvpnserviceHttpBinding"),
"http://schemas.xmlsoap.org/soap/http");
}
{
AbstractSoapBinding soapBinding = asf.createSoap11Binding(service0,
new QName("http://vpnservice.webservice.zlkj.com",
"jjzdvpnservicePortTypeLocalBinding"),
"urn:xfire:transport:local");
}

下面是整个类源码

import java.net.MalformedURLException;
import java.net.URLEncoder;
import java.util.Collection;
import java.util.HashMap;
import javax.xml.namespace.QName;
import org.codehaus.xfire.XFireRuntimeException;
import org.codehaus.xfire.aegis.AegisBindingProvider;
import org.codehaus.xfire.annotations.AnnotationServiceFactory;
import org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.jaxb2.JaxbTypeRegistry;
import org.codehaus.xfire.service.Endpoint;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
import org.codehaus.xfire.soap.AbstractSoapBinding;
import org.codehaus.xfire.transport.TransportManager;

public class jjzdvpnserviceClient {

private static XFireProxyFactory proxyFactory = new XFireProxyFactory();
private HashMap endpoints = new HashMap();
private Service service0;

@SuppressWarnings("unchecked")
public jjzdvpnserviceClient() {
    create0();
    Endpoint jjzdvpnservicePortTypeLocalEndpointEP = service0.addEndpoint(
            new QName("http://vpnservice.webservice.zlkj.com",
                    "jjzdvpnservicePortTypeLocalEndpoint"), new QName(
                    "http://vpnservice.webservice.zlkj.com",
                    "jjzdvpnservicePortTypeLocalBinding"),
            "xfire.local://jjzdvpnservice");
    endpoints.put(new QName("http://vpnservice.webservice.zlkj.com",
            "jjzdvpnservicePortTypeLocalEndpoint"),
            jjzdvpnservicePortTypeLocalEndpointEP);
    Endpoint jjzdvpnserviceHttpPortEP = service0.addEndpoint(new QName(
            "http://vpnservice.webservice.zlkj.com",
            "jjzdvpnserviceHttpPort"), new QName(
            "http://vpnservice.webservice.zlkj.com",
            "jjzdvpnserviceHttpBinding"),
            "http://127.0.0.1:9080/traplugin/services/jjzdvpnservice");
    endpoints.put(new QName("http://vpnservice.webservice.zlkj.com",
            "jjzdvpnserviceHttpPort"), jjzdvpnserviceHttpPortEP);
}

public Object getEndpoint(Endpoint endpoint) {
    try {
        return proxyFactory.create((endpoint).getBinding(),
                (endpoint).getUrl());
    } catch (MalformedURLException e) {
        throw new XFireRuntimeException("Invalid URL", e);
    }
}

public Object getEndpoint(QName name) {
    Endpoint endpoint = ((Endpoint) endpoints.get((name)));
    if ((endpoint) == null) {
        throw new IllegalStateException("No such endpoint!");
    }
    return getEndpoint((endpoint));
}

public Collection getEndpoints() {
    return endpoints.values();
}

@SuppressWarnings("unchecked")
private void create0() {
    TransportManager tm = (org.codehaus.xfire.XFireFactory.newInstance()
            .getXFire().getTransportManager());
    HashMap props = new HashMap();
    props.put("annotations.allow.interface", true);
    AnnotationServiceFactory asf = new AnnotationServiceFactory(
            new Jsr181WebAnnotations(), tm, new AegisBindingProvider(
                    new JaxbTypeRegistry()));
    asf.setBindingCreationEnabled(false);
    service0 = asf.create((com.zlkj.drvschool.webservice.jjzdvpnservicePortType.class),props);
    {
        AbstractSoapBinding soapBinding = asf.createSoap11Binding(service0,
                new QName("http://vpnservice.webservice.zlkj.com",
                        "jjzdvpnserviceHttpBinding"),
                "http://schemas.xmlsoap.org/soap/http");
    }
    {
        AbstractSoapBinding soapBinding = asf.createSoap11Binding(service0,
                new QName("http://vpnservice.webservice.zlkj.com",
                        "jjzdvpnservicePortTypeLocalBinding"),
                "urn:xfire:transport:local");
    }
}

public jjzdvpnservicePortType getjjzdvpnservicePortTypeLocalEndpoint() {
    return ((jjzdvpnservicePortType) (this).getEndpoint(new QName(
            "http://vpnservice.webservice.zlkj.com",
            "jjzdvpnservicePortTypeLocalEndpoint")));
}

public jjzdvpnservicePortType getjjzdvpnservicePortTypeLocalEndpoint(
        String url) {
    jjzdvpnservicePortType var = getjjzdvpnservicePortTypeLocalEndpoint();
    org.codehaus.xfire.client.Client.getInstance(var).setUrl(url);
    return var;
}

public jjzdvpnservicePortType getjjzdvpnserviceHttpPort() {
    return ((jjzdvpnservicePortType) (this).getEndpoint(new QName(
            "http://vpnservice.webservice.zlkj.com",
            "jjzdvpnserviceHttpPort")));
}

public jjzdvpnservicePortType getjjzdvpnserviceHttpPort(String url) {
    jjzdvpnservicePortType var = getjjzdvpnserviceHttpPort();
    org.codehaus.xfire.client.Client.getInstance(var).setUrl(url);
    return var;
}

}

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)