内网原有一台数据库服务库服务器,定时采集气象图片资料,存放在数据库中.大小从2k-2M.
现在想在外网设一台WEB服务器对外发布气象信息.两台服务器之间通过webservice交换数据.
简单地说,就是通过webservice发布图片(该文件存放在数据库字段中).
请问:这样的功能适合用webservice来实现吗?在效率上会不会有问题?

解决方案 »

  1.   

    内网应该是是无需被除你自己公司以外的程序调用的,而webservice虽然也有安全保证,但是终究是通过http/soap的;
    从完全和调用服务上来讲,你公司个人调用其实未必要一定用webservice,EJB应该更加的合适,他完全可以用jndi远程调用,而且方便作为一个组件,更方便以后复用,再者他是rmi传输的,比较适合一个公司内部调用,呵呵
      

  2.   

    web service 主要是解决跨应用系统,跨组织机构的平台对接,既然都是自己公司的,那就不必用web service了,web service虽然提供安全机制,但总是以http 发送的,可以用jndi来调用,将原来的系统改一改,就可以了。
      

  3.   

    谢谢上面两位.
    不过我已经说了,数据源在内网,外网放置WEB服务器,供外部访问.之所以想用WS,就是想在不改动原应用的基础上,再加上一个标准的对外服务接口,以方便以后的二次开放及与外部的数据交换.
    我现在最耽心的,其实是http方式传输的效率问题.因为源数据都是放在数据库字段里的,所以也不可能用FTP这些方式.
    还请大家继续支招,谢谢.
      

  4.   

    把图片解释成 btye数据发送过去,就行了.
    对方再解释成图片.
      

  5.   

    通过一个上传图片的服务演示 MTOM 的开发                    MTOM 提供了在 Web Services 中处理大的二进制数据的方法。                    使用 MTOM非常简单,在代码中加入    service.setProperty("mtom-enabled", "true");       或者在 services.xml文件中配置:    <service>      ... normal service definition      <properties>        <property key="mtom-enabled">true</property>      </properties>    </service>       在客户端代码中也要进行相应的配置:    MyService myClient = ...;    Client client = Client.getInstance(myClient);    client.setProperty("mtom-enabled", "true");       Aegis支持下列类的优化:        ●  DataSource        ●  DataHandler        ●  byte[]  你也可以实现一个自己的类型,只需继承 AbstractXOPType。         任何在 schema中的base64Binary都可使用 JAXB优化。你也可以指定期望的 mime 类型:
     <s:element name="GetPictureResponse">        <s:complexType>          <s:sequence>             <s:element name="image" type="s:base64Binary"     xmime:expectedContentTypes="image/jpeg"/>          </s:sequence>        </s:complexType>      </s:element> 
    JAXB足够聪明,使用Image 对象代替byte[]。         现在给你提一个需要,创建一个 Web Service ,用户可以使用它上传图片,如何做?         服务的接口如下:
    package com.googlepages.smallnest.facet;    public interface PictureService    {            public boolean uploadPicture(byte[] data,String name);    }         实现类:    package com.googlepages.smallnest.facet;    import java.io.File;    import java.io.FileNotFoundException;    import java.io.FileOutputStream;    import java.io.IOException;    public class PictureServiceImpl implements PictureService    {  public boolean uploadPicture(byte[] data, String name)              {                       try                       {                               File image = new File(name);                               image.createNewFile();                               FileOutputStream out = new FileOutputStream(name);                               out.write(data);                               out.close();                               System.out.println(image.getAbsolutePath());                       }                       catch (FileNotFoundException e)                       {                               return false;                       }                       catch (IOException e)                       {                               return false;                       } 
     return true;              }     } 
     services.xml文件:<beans>       <service xmlns="http://xfire.codehaus.org/config/1.0">         <name>PictureService</name>         <namespace>http://smallnest.googlepages.com/PictureService</namespace>         <serviceClass>com.googlepages.smallnest.facet.PictureService</serviceClass>         <implementationClass>com.googlepages.smallnest.facet.PictureServiceImpl</implementationC     lass>         <properties>              <property key="mtom-enabled">true</property>              </properties>       </service>     </beans> 发布这个服务,等待客户端上传。
    下面创建一个客户端进行测试。          在 eclipse 中创建一个Java工程,利用 Ant和上面的 Web Service 的 WSDL生成客 户端的访问代码。创建 FacetClient类:
    package com.googlepages.smallnest.facet;     import java.io.FileInputStream;     import java.io.FileNotFoundException;     import java.io.IOException;     public class FacetClient     {              public static void main(String[] args)              {                      PictureServiceClient client = new PictureServiceClient();                      PictureServicePortType pictureService = client.getPictureServiceHttpPort();                      FileInputStream in;                      try                      {                               in = new FileInputStream("girl.jpg");                               byte[] data = new byte[in.available()];                                in.read(data); //图片不大                               in.close();                               boolean b = pictureService.uploadPicture(data, "good.jpg");                               System.out.println(b); 
    }                      catch (FileNotFoundException e)                      {                               e.printStackTrace();                      }                      catch (IOException e)                      {                               e.printStackTrace();                      }              }     } 
     运行这个程序,在 Tomcat相应的目录查看上传的结果:我也从Xfire-野猪书-开发指南2.pdf 里  学习到的,在这里,也感谢“野猪”书的作者啦。
    有什么不懂的话,可以Email to : [email protected]