• 大小: 26KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-26
  • 语言: Java
  • 标签: Web  

资源简介

Web Service示例。不知道如何写WEB service程序,那就认真看看这个实例吧!

资源截图

代码片段和文件信息


package com.accp.client;

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;

public class BookServiceClient {

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

    public BookServiceClient() {
        create0();
        Endpoint BookServicePortTypeLocalEndpointEP = service0 .addEndpoint(new QName(“http://xfire.accp.com“ “BookServicePortTypeLocalEndpoint“) new QName(“http://xfire.accp.com“ “BookServicePortTypeLocalBinding“) “xfire.local://BookService“);
        endpoints.put(new QName(“http://xfire.accp.com“ “BookServicePortTypeLocalEndpoint“) BookServicePortTypeLocalEndpointEP);
        Endpoint BookServiceHttpPortEP = service0 .addEndpoint(new QName(“http://xfire.accp.com“ “BookServiceHttpPort“) new QName(“http://xfire.accp.com“ “BookServiceHttpBinding“) “http://localhost:8080/xfire-server/services/BookService“);
        endpoints.put(new QName(“http://xfire.accp.com“ “BookServiceHttpPort“) BookServiceHttpPortEP);
    }

    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((com.accp.client.BookServicePortType.class) props);
        {
            AbstractSoapBinding soapBinding = asf.createSoap11Binding(service0 new QName(“http://xfire.accp.com“ “BookServicePort

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        645  2008-12-03 18:20  xfire-client\.classpath

     文件        309  2008-12-03 18:11  xfire-client\.mymetadata

     文件       1014  2008-12-03 18:11  xfire-client\.project

     文件       4610  2008-12-03 18:20  xfire-client\src\com\accp\client\BookServiceClient.java

     文件        878  2008-12-03 18:20  xfire-client\src\com\accp\client\BookServicePortType.java

     文件       1467  2008-12-03 18:28  xfire-client\src\com\accp\test\BookTest.java

     文件       1464  2008-12-03 18:20  xfire-client\src\com\accp\xfire\AddBook.java

     文件       1229  2008-12-03 18:20  xfire-client\src\com\accp\xfire\AddBookResponse.java

     文件       1869  2008-12-03 18:20  xfire-client\src\com\accp\xfire\ArrayOfBook.java

     文件       4872  2008-12-03 18:20  xfire-client\src\com\accp\xfire\Book.java

     文件        748  2008-12-03 18:20  xfire-client\src\com\accp\xfire\GetAllBook.java

     文件       1528  2008-12-03 18:20  xfire-client\src\com\accp\xfire\GetAllBookResponse.java

     文件       3906  2008-12-03 18:20  xfire-client\src\com\accp\xfire\objectFactory.java

     文件        168  2008-12-03 18:20  xfire-client\src\com\accp\xfire\package-info.java

     文件         39  2008-12-03 18:11  xfire-client\WebRoot\meta-INF\MANIFEST.MF

     文件       5422  2008-12-03 18:20  xfire-client\WebRoot\WEB-INF\classes\com\accp\client\BookServiceClient.class

     文件        796  2008-12-03 18:20  xfire-client\WebRoot\WEB-INF\classes\com\accp\client\BookServicePortType.class

     文件       3032  2008-12-03 18:28  xfire-client\WebRoot\WEB-INF\classes\com\accp\test\BookTest.class

     文件        916  2008-12-03 18:20  xfire-client\WebRoot\WEB-INF\classes\com\accp\xfire\AddBook.class

     文件        797  2008-12-03 18:20  xfire-client\WebRoot\WEB-INF\classes\com\accp\xfire\AddBookResponse.class

     文件        962  2008-12-03 18:20  xfire-client\WebRoot\WEB-INF\classes\com\accp\xfire\ArrayOfBook.class

     文件       2171  2008-12-03 18:20  xfire-client\WebRoot\WEB-INF\classes\com\accp\xfire\Book.class

     文件        562  2008-12-03 18:20  xfire-client\WebRoot\WEB-INF\classes\com\accp\xfire\GetAllBook.class

     文件        981  2008-12-03 18:20  xfire-client\WebRoot\WEB-INF\classes\com\accp\xfire\GetAllBookResponse.class

     文件       2713  2008-12-03 18:20  xfire-client\WebRoot\WEB-INF\classes\com\accp\xfire\objectFactory.class

     文件        321  2008-12-03 18:20  xfire-client\WebRoot\WEB-INF\classes\com\accp\xfire\package-info.class

     文件        288  2008-12-03 18:11  xfire-client\WebRoot\WEB-INF\web.xml

     文件        439  2008-12-03 16:56  xfire-server\.classpath

     文件        309  2008-12-03 16:56  xfire-server\.mymetadata

     文件       1416  2008-12-03 17:20  xfire-server\.project

............此处省略50个文件信息

评论

共有 条评论