SSH项目和XFire(WebService)整合 好后测试时抱一下错误............由于本人刚上手,属菜鸟.........敬请各路神仙给予指点.........

这是SSH项目和XFire整合自动生成的代码及自己写的测试代码........<测试代码尽在下面mian方法中.....>
package test;

import java.net.MalformedURLException;
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.soap.AbstractSoapBinding;
import org.codehaus.xfire.transport.TransportManager;

import dao.Customers;

public class CustomerServiceClient {

    private static XFireProxyFactory proxyFactory = new XFireProxyFactory();

    private HashMap endpoints = new HashMap();

    private Service service0;

    public CustomerServiceClient() {
        create0();
        Endpoint CustomerServiceHttpPortEP = service0.addEndpoint(new QName(
                "http://service", "CustomerServiceHttpPort"), new QName(
                "http://service", "CustomerServiceHttpBinding"),
                "http://localhost:8088/ZhengHe/services/CustomerService");
        endpoints.put(new QName("http://service", "CustomerServiceHttpPort"),
                CustomerServiceHttpPortEP);
        Endpoint CustomerServicePortTypeLocalEndpointEP = service0.addEndpoint(
                new QName("http://service",
                        "CustomerServicePortTypeLocalEndpoint"),
                new QName("http://service",
                        "CustomerServicePortTypeLocalBinding"),
                "xfire.local://CustomerService");
        endpoints.put(new QName("http://service",
                "CustomerServicePortTypeLocalEndpoint"),
                CustomerServicePortTypeLocalEndpointEP);
    }

    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();
    }

    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((test.CustomerServicePortType.class), props);
        {
            AbstractSoapBinding soapBinding = asf.createSoap11Binding(service0,
                    new QName("http://service", "CustomerServiceHttpBinding"),
                    "http://schemas.xmlsoap.org/soap/http");
        }
        {
            AbstractSoapBinding soapBinding = asf.createSoap11Binding(service0,
                    new QName("http://service",
                            "CustomerServicePortTypeLocalBinding"),
                    "urn:xfire:transport:local");
        }
    }

    public CustomerServicePortType getCustomerServiceHttpPort() {
        return ((CustomerServicePortType) (this).getEndpoint(new QName(
                "http://service", "CustomerServiceHttpPort")));
    }

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

    public CustomerServicePortType getCustomerServicePortTypeLocalEndpoint() {
        return ((CustomerServicePortType) (this).getEndpoint(new QName(
                "http://service", "CustomerServicePortTypeLocalEndpoint")));
    }

    public CustomerServicePortType getCustomerServicePortTypeLocalEndpoint(
            String url) {
        CustomerServicePortType var = getCustomerServicePortTypeLocalEndpoint();
        org.codehaus.xfire.client.Client.getInstance(var).setUrl(url);
        return var;
    }
//测试,冲数据库中取出一条记录........
    public static void main(String[] args) {

        CustomerServiceClient client = new CustomerServiceClient();

        //create a default service endpoint
        CustomerServicePortType customerServicePortType = client
                .getCustomerServiceHttpPort();
        Customers c=customerServicePortType.login("bb", "22");
        System.out.println(c.getRealname().getValue());
       
        //TODO: Add custom client code here
        //
        //customerServicePortType.yourServiceOperationHere();

        System.out.println("test client completed");
        System.exit(0);
    }

}

 

 

 

Exception in thread "main" org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: failed to lazily initialize a collection of role: dao.Customers.orderses, no session or session was closed
org.codehaus.xfire.fault.XFireFault: failed to lazily initialize a collection of role: dao.Customers.orderses, no session or session was closed
    at org.codehaus.xfire.fault.Soap11FaultSerializer.readMessage(Soap11FaultSerializer.java:31)
    at org.codehaus.xfire.fault.SoapFaultSerializer.readMessage(SoapFaultSerializer.java:28)
    at org.codehaus.xfire.soap.handler.ReadHeadersHandler.checkForFault(ReadHeadersHandler.java:111)
    at org.codehaus.xfire.soap.handler.ReadHeadersHandler.invoke(ReadHeadersHandler.java:67)
    at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
    at org.codehaus.xfire.client.Client.onReceive(Client.java:382)
    at org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:139)
    at org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
    at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
    at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
    at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:75)
    at org.codehaus.xfire.client.Client.invoke(Client.java:335)
    at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
    at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
    at $Proxy12.login(Unknown Source)
    at test.CustomerServiceClient.main(CustomerServiceClient.java:122)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值