已经比较熟悉DELPHI,但还不会分布式,JAVA也已入门,如何用JAVA和DELPHI一起做多层呢?请给范例,网站具体链接也行
用了DELPHI有一段时间了,从四年前从D2、D3开始学,但真正是从去年才开始用D6直到现在,仅对DELPHI和JAVA较有兴趣,会用JAVA写简单的BEAN,也会用DELPHI改写控件,但没有深入到DELPHI的分布式开发想知道如何用JAVA写服务器端运行的程序,用DELPHI在客户端检验数据和显示数据,希望各位能提供方法以参考,最好是XML格式的数据交换可能概念有点乱,这也正是我当前最急的帮我UP也有分提供有效帮助,另外再送分,要多少给多少,倾家荡产都行,来这个世界时,我本赤裸,只求有个归宿本人很少提问,但经常帮别人UP,赚得的积分根本用不完希望这次大伙能帮我

解决方案 »

  1.   

    如果UP真的有分的话,那么我将UP一万次!嘿嘿
    UP
      

  2.   

    JAVA?JAVA不会,帮不了你,不好意思
      

  3.   

    To:gmc007(江西的佬表) Up当然有分,但只按人头算,不按次数算我是江西宜春市,兄台是哪的呀?:-)
      

  4.   

    靠,我也是和你差不多,现在正在用delphi在一家公司写程序,以前用的是VB,现在这两种都还可以了,但就是不会做多层的应用,可又急需找到学习的入口,一起UP。
      

  5.   

    过来了,可是我也不懂。只知道最最最皮毛的东西。
    *******************************************************************
    java.lang.Processabstract  void destroy() 
              Kills the subprocess. 
    abstract  int exitValue() 
              Returns the exit value for the subprocess. 
    abstract  InputStream getErrorStream() 
              Gets the error stream of the subprocess. 
    abstract  InputStream getInputStream() 
              Gets the input stream of the subprocess. 
    abstract  OutputStream getOutputStream() 
              Gets the output stream of the subprocess. 
    abstract  int waitFor() 
              causes the current thread to wait, if necessary, until the process represented by this Process object has terminated. 
    ******************************************************************* 
    java.lang.RuntimeProcess exec(String command) 
              Executes the specified string command in a separate process. 
     Process exec(String[] cmdarray) 
              Executes the specified command and arguments in a separate process. 
     Process exec(String[] cmdarray, String[] envp) 
              Executes the specified command and arguments in a separate process with the specified environment. 
     Process exec(String[] cmdarray, String[] envp, File dir) 
              Executes the specified command and arguments in a separate process with the specified environment and working directory. 
     Process exec(String cmd, String[] envp) 
              Executes the specified string command in a separate process with the specified environment. 
     Process exec(String command, String[] envp, File dir) 
              Executes the specified string command in a separate process with the specified environment and working directory. 
    static Runtime getRuntime() 
              Returns the runtime object associated with the current Java application. 
    *******************************************************************
    Dephi我不清楚,不过VB有个API声明:Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
      

  6.   

    摩托给点建议:    java和其他语言直接整合一般配置很繁杂。我觉得的用webservice
    比较方便。你用java写ejb组件,用java的做成webservice(其实用
    delphi也可以做服务来引用beans),客户端用delphi很容易实现。
      

  7.   

    To monkely()  一起学习to Iforgot(清风雨)
     很抱歉,一点也看不懂to 摩托
     能不能给个示例呢?或是网址联连,或是书本链接(仅电子版,穷啊),多谢:-)。
      

  8.   

    SORRY!
    我在java看到你的提问,谁知道,是关于delphi和java的结合使用问题!
    我不会delphi,不好意思!
      

  9.   

    摩托 ^_^(连接找不到了)没有图

    EJB是使用Java语言编写分布式的、面向对象的、商业应用的标准组件架构(参见EJB 1.1规范)。一些企业正在将他们以前的基于COM+组件的应用移植到EJB组件技术,或者采用EJB构建新的应用,同时为保护以前的IT投入还要保留以前的采用Delphi或者Visual Basic等编程语言编写的客户端应用。这就提出了Delphi/Visual Basic访问EJB的需求。本篇文章将首先介绍Delphi/Visual Basic访问EJB的两种方法,然后介绍Delphi/Visual Basic如何通过Web Service访问EJB: 将EJB封装为Web Service并发布到应用服务器上 
    Delphi访问Web Service 
    Visual Basic访问Web Service 最后文章中讨论了在Delphi和Visual Basic中调用Web service时遇到的中文问题。Delphi/Visual Basic访问EJB的两种方法 
    Delphi通过CORBA ORB访问EJB
    Delphi企业版中含有CORBA Visibroker server,可以在Borland App Server服务器端将EJB封装为CORBA服务,然后在客户端用SIDL (Simple IDL)的来描述封装EJB的CORBA服务,最后用Delphi工具idl2pas将描述文件翻译成pascal程序。这个方案在部署的时候需要在客户端安装Visibroker server。 
    Visual Basic通过ActiveX to EJB Bridge访问EJB
    IBM WebSphere Application Server Enterprise Edition 4.x中的Enterprise Service当中包含ActiveX to EJB bridge,它为VB、VBScript以及ASP提供了一个ActiveX组件来方便地访问EJB。 客户端程序首先初始化一个ActiveX控件,该控件初始化一个Java虚拟机,ActiveX控件和Java虚拟机通过JNI(Java Native Interface)的方式交互。Java虚拟机通过Java ORB和运行在应用服务器上的EJB进行交互。Active Bridge支持使用J2EE Client Container或者直接通过JNDI的方式访问EJB。图一:ActiveX to EJB Bridge系统结构
    通过Web Service让Delphi/Visual Basic访问EJB 
    采用Web Service的方式封装EJB,我们理论上可以让支持Web Service的任何编程语言来访问该EJB,比如Java, Visual Basic, Visual C++,Delphi,perl,PHP等。将EJB封装为web service的工具有很多种,这里我们以开放源码的Apache SOAP为例来说明这个开发流程,开发工具采用WSAD(IBM WebSphere Studio Application Developer)。这是一个以Java语言编写的,可以运行在Windows和Linux平台上的J2EE开发工具,支持servlet、jsp、ejb、web service和xml的开发和调试,可以在http://www-3.ibm.com/software/ad/studioappdev/免费下载试用版。我们将以一个程序员都非常熟悉的例子-HelloWorld来展示开发流程。下面,是我们动手开始做的时间了!第一步,编写一个EJB,名字叫做HelloWorld。1)建立一个EJB项目(EJB project):在J2EE perspective选择菜单File > New > EJB Project,输入Project Name为HelloWorldEJB,Enterprise Application project name为HelloWorldEAR,选择Finish建立该EJB项目,如图二所示:
    图二:建立EJB项目
    2)建立EJB:在J2EE perspective中的J2EE View中选择EJB Modules > HelloWorldEJB,然后选择菜单File > New > Enterprise Bean,输入Bean Name为HelloWorld,Bean class为ejbs.HelloWorld(这里使用package名为ejbs)。选择Finish建立该EJB。如图三所示:
    图三 建立EJB
    3)给HelloWorldBean添加一个方法:在J2EE perspective中的J2EE View中选择EJB Modules > HelloWorldEJB > HelloWorld > HelloWorldBean,鼠标双击打开并编辑该EJB。在该EJB后面加入方法sayHelloWorld 
    /** sayHello
     * @return "Hello someone"
       * @param theName the name of someone
     */
    public String sayHello(String theName) {
    return "Hello " + theName;
    } 图四 给HelloWorldBean增加一个方法sayHello
    4)将新添加的方法sayHello加入到EJB remote interface中:鼠标选中WSAD左下角处Java的Outline窗口中的方法sayHelloWorld,选择鼠标右键菜单Enterprise Bean > Promote to Remote Interface。WSAD将在HelloWorld EJB的remote Interface HelloWorld中加入一行: public String sayHello(String theName) throws java.rmi.RemoteException; 
    远程接口HelloWorld.java的完整的代码: 
    package ejbs;
    /**
     * Remote interface for Enterprise Bean: HelloWorld
     */
    public interface HelloWorld extends javax.ejb.EJBObject {
    /** sayHello
     * @return "Hello someone"
       * @param theName the name of someone
     */
    public String sayHello(String theName) throws java.rmi.RemoteException;
    } 图五 将新添加的方法sayHello加入到EJB remote interface中
    5)让WSAD生成EJB的部署代码(Deploy code)。如图六操作即可。
    图六 生成EJB的部署代码
    6)现在我们可以部署并测试HelloWorld EJB了! 如图七所示,运行HelloWorld EJB。 
    图七 选择在服务器上运行EJB
    我们将看到WSAD将这个EJB项目发布到一个WebSphere v4.0 Test Environment中,启动该WebSphere测试环境。在控制台中可以看到 
    02.04.14 11:56:59:171 CST] 55e67dfe EJBEngine     I WSVR0037I:正在启动 EJB jar:HelloWorldEJB
    [02.04.14 11:56:59:661 CST] 55e67dfe EJBEngine     I WSVR0038I:未找到 HelloWorld 的 JNDI 名,绑定起始对象名为 HelloWorldHome

    [02.04.14 11:57:05:830 CST] 55e67dfe Server        A WSVR0023I:服务器 Default Server 为电子商务开放 
    最后WSAD将打开一个EJB Test Client窗口。选择EJB References > HelloWorld > HelloWorldHome > HelloWorld create()方法,EJB Test Client获得一个HelloWorld EJB Home Stub。如图八所示:
    图八 使用EJB Test Client测试EJB(1)
    7)调用HelloWorld EJB Home Stub对象的方法sayHello测试EJB。
    图九 使用EJB Test Client测试EJB(2)
    第二步,使用WSAD中的 Web Service生成向导生成包装该EJB的Web Service、测试该Web Service的java proxy(一个Java Bean)和JSP测试程序,最后运行生成的程序来测试这个Web Service。1)建立一个名叫HelloWorldWeb的Web Project:选择菜单File > New > Web Project,输入project name为HelloWorldWeb,选择Enterprise Application project name为HelloWorldEAR,如图十所示。选择next命令按钮,选中available dependent JARs HelloWorldEJB.jar,如图十一所示。
    图十 
     图十一 
     
    选择HelloWorldWeb > source,选择菜单File > New > Web Service,如图十二所示:
    图十二
    在"Web Service"窗口中选择部署该Web Service的Web project为HelloWorldWeb,如图十三所示:
    图十三
    选择Next进入下一个向导窗口,选择Web service type为EJB Web service。选择Next进入下一个向导窗口,选择命令按钮"Browse EJB Bean…",在弹出窗口中选择EAR Project为HelloWorldEAR,EJB bean为HelloWorld(如图十四所示)
      

  10.   


    图十四
    关闭弹出窗口,输入EJB JNDI name 为HelloWorldHome,如图十五所示。
    图十五
    选择Next进入下一个向导窗口,向导将要求输入Web service URI的名称和多个描述文件的文件名,如图十六、十七所示。Web service URI是符合uniform resource Naming convention标准(http://www.ietf.org/rfc/rfc2141.txt)web service的标识符,应用程序访问Web service的时候需要指定这个参数。ISD文件是Apache SOAP内部使用的web service的发布描述文件。/wsdl/HelloWorld-service.wsdl文件描述了相关的web service port信息,应用程序可以通过该文件获得服务器上各种web service的信息。 
    <?xml version="1.0" encoding="UTF-8"?>
    <definitions name="HelloWorldService" 
    targetNamespace="http://localhost:8080/HelloWorldWeb/wsdl/HelloWorld-service.wsdl"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://localhost:8080/HelloWorldWeb/wsdl/HelloWorld-service.wsdl"
    xmlns:binding="http://www.helloworld.com/definitions/HelloWorldRemoteInterface"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
      <import namespace="http://www.helloworld.com/definitions/HelloWorldRemoteInterface"
    location="http://localhost:8080/HelloWorldWeb/wsdl/HelloWorld-binding.wsdl"/>
      <service name="HelloWorldService">
        <port name="HelloWorldPort" binding="binding:HelloWorldBinding">
          <soap:address location="http://localhost:8080/HelloWorldWeb/servlet/rpcrouter"/>
        </port>
      </service>
    </definitions>
     /wsdl/HelloWorld-bind.wsdl则具体定义了具体一个portType的操作和消息的消息格式和协议。
    <?xml version="1.0" encoding="UTF-8"?>
    <definitions name="HelloWorldRemoteInterface"
    targetNamespace="http://www.helloworld.com/definitions/HelloWorldRemoteInterface"
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:tns="http://www.helloworld.com/definitions/HelloWorldRemoteInterface"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
      <message name="sayHelloRequest">
        <part name="theName" type="xsd:string"/>
      </message>
      <message name="sayHelloResponse">
        <part name="result" type="xsd:string"/>
      </message>
      <portType name="HelloWorldJavaPortType">
        <operation name="sayHello">
          <input name="sayHelloRequest" message="tns:sayHelloRequest"/>
          <output name="sayHelloResponse" message="tns:sayHelloResponse"/>
        </operation>
      </portType>
      <binding name="HelloWorldBinding" type="tns:HelloWorldJavaPortType">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="sayHello">
          <soap:operation soapAction="" style="rpc"/>
          <input name="sayHelloRequest">
            <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://tempuri.org/ejbs.HelloWorld"/>
          </input>
          <output name="sayHelloResponse">
            <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://tempuri.org/ejbs.HelloWorld"/>
          </output>
        </operation>
      </binding>
    </definitions> 图十六图十七
    3)WSAD可以生成访问刚才发布的Web service的Java类,如图十八、十九所示。该类的方法 public synchronized java.lang.String sayHello(java.lang.String theName) throws Exception包装了发布为Web service的EJB HelloWorld的方法sayHello(java.lang.String theName)。在发布EJB为Web service的向导中可以生成这个Java类(web service binding proxy),同时还可以生成使用这个类访问web service的jsp页面。
    图十八图十九
    最后,你可以选择将Web Service发布为到UDDI服务器(比如免费的IBM的UDDI4J)上。第三步,在Delphi中调用Web Service使用Delphi Web Services importer将定义Web Service的WSDL文件(可以是从Web服务器上下载下来的本地wsdl文件,也可以是一个指向该文件的HTTP URL,比如http://localhost:8080/HelloWorldWeb/wsdl/HelloWorld-service.wsdl)导入,这将自动生成定义和注册interfaces and types的pascal代码。选择菜单File > New > Other… > 出现New Iterms窗口,选择WebServices,选择Web Services importer。如图二十、二十一所示:
    图二十图二十一
    生成的代码如下: 
    Unit Unit_2;
    interface
    uses Types, XSBuiltIns;
    typeHelloWorldJavaPortType = interface(IInvokable)
        ['{521A5B71-4CB9-4FAA-82AD-0F9CCF423FB9}'] 
    //为方便使用,我们把Delphi声明的过程 sayHello改为方法
        //procedure sayHello(const theName: WideString; out result: WideString);  stdcall;
    function sayHello(const theName: WideString): WideString;  stdcall; 
    end;
    implementation
    uses InvokeRegistry;
    initialization
      InvRegistry.RegisterInterface(TypeInfo(HelloWorldJavaPortType), '', 'UTF-8'); 
    end. 
    现在,我们可以利用THTTPRio对象来调用Web Service。THTTPRio是Delphi提供的支持SOAP over HTTP的有源代码的SOAP支持类库。部分代码如下: 

    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, SoapHTTPClient, Unit2, StdCtrls;

    procedure TForm_main.Button_callClick(Sender: TObject);
    var
            //使用Delphi的Unit SoapHTTPClient,Delphi
            X :THTTPRio;
            //使用Unit_2中定义的HelloWorld Interface
            InterfaceVariable: HelloWorld;
            para1, para2: WideString;
    begin
            X := THTTPRio.Create(nil);
            //设置Delphi在提出HTTP请求的时候设置Content-Type为text/xml; charset= UTF-8
           X.HTTPWebNode.UseUTF8InHeader := true ;        //WSDLLocation也可以是在本地文件系统中的wsdl文件。
            X.WSDLLocation := 'http://localhost:8080/HelloWorldWeb/wsdl/HelloWorld-service.wsdl';
            
    // THTTPRio 的Service参数和Port参数对应HelloWorld-service.wsdl文件中的定义。
    // <service name="HelloWorldService">
    //    <port name="HelloWorldPort" binding="binding:HelloWorldBinding">
      //      <soap:address location="http://localhost:8080/HelloWorldWeb/servlet/rpcrouter"/>
       //    </port>
      //</service>
            X.Service := 'HelloWorldService';
            X.Port := 'HelloWorldPort';        InterfaceVariable := X as HelloWorld;
            para1 := '中文';
            //从输入文本框中获得输入参数
            para1 := Edit_para1.Text;
            para2 := InterfaceVariable.sayHello(para1);
            //显示调用web service返回的结果
            Label_return_value.Caption := 'Return Value: ' + para2;
            X.free;
    end;
     
      

  11.   

    COROB
    RMI
    Web Service
    Socket(自己开发协议,或者定义XML)
      

  12.   

    跨语言的,跨工具的开发,本来就是一个比较麻烦的问题,而你现在需要还是在两种没有一点关系的工具之间的协调开发,不是说不能开发,而是这样的话,可能你就浪费工具本上给你提供的功能了!使用CORBA完全可以开发达到你说的这个的要求,至于说RMI我认为不可能,SOCKET的话,那就麻烦的简直可以去自杀,WEB SERVICE的话,建议你还是不要采用,D版的不好用,Z搬的很难买起,再说了,人家WEB SERVICE并不是为了支持跨语言开发的!如果你采用XML的话,倒是个不错的主义!如果是我,我绝对不会选择delphi 跟java配合!
      

  13.   

    为什么要用JAVA 和 DELPHI ...
    up一下。
      

  14.   

    TO  del_c_sharp(摩托还需骆拉)很抱歉,只能给您100分完整的配图文章在这里http://www-900.ibm.com/developerWorks/cn/webservices/ws-ejbacess/index.shtml我下午找到的收藏了,还没看。吃饭过来一看,您也找到了,不过您未贴图,所以只给您100分,希望不要介意