最好用web service,比直接使用soap简单,方便

解决方案 »

  1.   

    to rainight(雨夜聆风):
    soap也是一种web service ,我现在已经写出来一个soap客户端程序,它的原理就是向web server的一个servlet请交一个http请求。web server上的一个servlet也可以获取这个请求,但是现在我不知道web server如何读出soap请求内容,即:不知道如何取得请求的xml文档。怎样编写soap服务器端?怎样解析提交的文档?怎样发送回去一个SOAP响应?
      

  2.   

    建议你用jb7作为开发工具,安装jb7的web service插件,可以自动生成 soap server,然后在tomcat或weblogic等应用服务器上部署,通过访问通过访问相应的url,可以得到wsdl文档,jb7可以倒入这个url,生成相应的java类,你可以根据这些类进行client开发。
      

  3.   

    server端举例:public class ExchangeRate_ServiceBinding
    {
    public static java.net.URL[] _KnownServiceLocations= null;
    private org.apache.soap.rpc.Call call=new org.apache.soap.rpc.Call();
    private java.net.URL url= null;
    private java.lang.String SOAPActionURI = "";
    private org.apache.soap.encoding.SOAPMappingRegistry smr = call.getSOAPMappingRegistry();
    static
    {
    try{
    _KnownServiceLocations= new java.net.URL[]{
    new java.net.URL("http://localhost/soaprate/servlet/rpcrouter")
    };
    }catch(java.net.MalformedURLException e ){_KnownServiceLocations= new java.net.URL[0];};
    }
    public ExchangeRate_ServiceBinding(java.net.URL endPointURL)
    {
    call.setTargetObjectURI("urn:exchangerate-service");
    call.setEncodingStyleURI("http://schemas.xmlsoap.org/soap/encoding/");
    this.url = endPointURL;
    this.SOAPActionURI = "urn:exchangerate-service";
    }
    public synchronized java.lang.String getTargetAmount (java.lang.String meth3_inType1, java.lang.String meth3_inType2, java.lang.String meth3_inType3)  throws  org.apache.soap.SOAPException
    {
    if(url == null) throw new  org.apache.soap.SOAPException(org.apache.soap.Constants.FAULT_CODE_CLIENT, "A URL must be specified \"ExchangeRate_ServiceBinding\"." );
    this.call.setMethodName("getTargetAmount");
    java.util.Vector parms  = new java.util.Vector(3);
    parms.addElement( new org.apache.soap.rpc.Parameter("meth3_inType1", java.lang.String.class, meth3_inType1, null));
    parms.addElement( new org.apache.soap.rpc.Parameter("meth3_inType2", java.lang.String.class, meth3_inType2, null));
    parms.addElement( new org.apache.soap.rpc.Parameter("meth3_inType3", java.lang.String.class, meth3_inType3, null));
    this.call.setParams(parms);
    org.apache.soap.rpc.Response resp = this.call.invoke(url, SOAPActionURI);
    if(resp.generatedFault())
    {
    org.apache.soap.Fault fault = resp.getFault();
    throw new  org.apache.soap.SOAPException(fault.getFaultCode(), fault.getFaultString());
    }
    return (java.lang.String)resp.getReturnValue().getValue(); 
    }
    }
      

  4.   

    用apache的 AXIS项目是一个web service服务,可以挂接在tomcat只类的东西中。
    写好你的服务器端核心逻辑程序代码,参考它的文档使用wsdl2java和java2wsdl两个工具可以生成所以你需要的代码,你就不用直接和soap打交道了,真的很方便,我刚做过。同时用wsdd文件部署好web服务就可以使用了。
    如有其他问题可以发信息给我。还有不要用jb的web service插件,因为这个插件也是用axis,但版本很低。推荐直接去apache网站下载一个最新班。个人感觉jms比soap传输起来方便很多,因为xml一旦数据多了,速度下降很明显。
      

  5.   

    soap只是webservice中解决传输协议的部分(只是一部分而已)。你能在客户端发送soap消息,意味着你也需要一个webservice的服务端,而不仅仅是一个web server,所以,你可以选择一些现成的webservice服务端,比如apache axis/soap等,或是weblogic701以后也可以。我也觉得从你的需求来看,用jms会好点,它的客户端并不复杂啊?几句话而已,发一个soap差不多也要几句话嘛。
      

  6.   

    to bdsc():
    socket适用于局域网,我需要能在internet上顺利通讯的解决方案啊。
    to sharetop(老大不小) :
    是的,我现在就是想要一个webservice,我手边没有讲jms和soap的书,有一本是讲j2ee的,稍带讲了讲jms,很诲涩难懂,网上也没找着好的教程。另外,jms客户端能用其他语言实现吗?有windows平台上的jms API吗?
      

  7.   

    jms_tutorial-1_3_1,sun的网站上有写的比较明白。
    axis www.apache.org上有。
    jms客户端好像只能用java,倒是jms的实现可以用多种语言来实现。
      

  8.   

    写个socket程序,服务器侦听,侦听到,就解析就可以了.
      

  9.   

    JMS只是一套规范,SUN定义了接口,让各个vendor去实现它。所以它的客户端只能是Java的。因为实现可以用不同的语言,所以在性能上有差异。效率上取决于各个vendor的实现,比如tibco的jms server,速度不错,而且它的实现与rendevouse相通,性能、安全性都非常不错。tibco在消息中间件方面做的相当有经验的。你可以从www.tibco.com下载这个jms的评估版(只能连续启动12hr)。但是正因为JMS只是一个规范,所以不管是谁实现的server,对你来说不重要,你不需要改动你的代码,只需要选择一个想要的vendor。而且,JMS在SUN的网站上有tutorial的。你可以去看一下,也有例子。包括weblogic的文档中也有文档也有例子,所以学习应该不成问题。
      

  10.   

    imho, you can think it as a data integration case, not a system integration one. From your description, the main purpose of your system is to gather the data from all diverse sub-systems. There are no relations with remote method invocation(rmi) or formerly called remote process call(rpc). All you need is sending data from every node. So the key aspect of your design shound be focused on creating a uniform message/data format. Of course, XML is your most suitable choice.And then choose the XML transfer method to implement your demand. SOAP is somewhat hot now for it can send XML through HTTP. So the SOAP over HTTPS will match your system. The last and the most boring thing is to write soap client code for every programing language the nodes used in your sub-systems. For example, you should use DELPHI to create a proxy, retrieving useful data, encapsulating to pre-defined XML format and transfering to the center storage system. Also you may have Java powered sub-system, MS powered ones like VB and VC, etc. Write that kind of SOAP client using those languages. I hope you have so many wonderful people working for you.Moreover, your consideration is correct on the problem you face - it is a message transfer problem. But do not choose some technologies SOUNDS LIKE catering your need. JMS is one kind of message services used in java system and mostly it will facilite loose-coupled system integration and asynthronized processing. Remember it is java-specific. On the other hand, web services let you invoke methods in remote machine and regardless whatever the OS, the programming language and so on in the remote machine. It is too powerful to your system - you want XML transfer, it give you remote method invocation. 
      

  11.   

    这与什么WEB SERVICE没有任何搭嘎吧.典型的数据传输问题.消息通信也罢,SOCKET也行.搞不明白为何要扯到什么WEB服务上去.
      

  12.   

    看了一点JMS文档,感觉好像JMS更适合做服务器与服务器端的通信,比如协调两个weblogic server工作什么的。
      

  13.   

    xue_sharp(你是自愿被我泡的) ,sharetop(燕赤霞) :
    谢谢指点,我去sun网站看了相关文档。
    我更趋向于weblogic中的jms server。to patrickwang():
    你觉得SOAP比JMS更适合解决我的问题?请留下QQ好吗?
      

  14.   

    其实用哪个JMS Server并不重要,将来你改server也不需要变代码,这就是标准的好处。:)如果你是用的Weblogic作为你的应用服务器,它的JMS当然是首选了。毕竟在速度不是太强求的情况下,它实现的一些功能(安全方面)是相当不错的了。JMS并不是用来协调两个server之间的通讯,这点可能是你理解错了。
      

  15.   

    我在用WEBLOGIC的JMS时.
    1 发现数据不完整.不适合做商业应用(像QQ一样的软件可考虑)
    2 数据传递问题.不管是XML数据格式,还是其它.都会是字节传输.
    3 还是考虑用WEB SERVICE.把数据压缩成流.调用远程接口进行传输.
    4 HTTP是一种透过防火墙的协议.与TCP/IP无关.(写代码不用考虑这些问题)
    5 在传输的时候最好加上头字节等信息.即数据包体.
    6 形成服务器与客户接收的CRC检验检查.
    7 这样可保证达到数据完整性.