1. 首先取得java-webservice服务器端地址。我的是:http://localhost:8080/mywebservice/services/mywebservice?wsdl

2. 然后打开delphi7,file-new-other:选择WebService选项卡,在选择WSDLImporter
,在弹出的界面中输入java-webservice地址。点击Next-finish.会生成一个.pas的webservice文件,

生成的代码如下:
Java代码 收藏代码
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://localhost:8080/mywebservice/services/mywebservice?wsdl
// Encoding : UTF-8
// Version : 1.0
// (2011-7-21 10:17:02 - 1.33.2.5)
// ************************************************************************ //

unit mywebservice;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

type

// ************************************************************************ //
// The following types, referred to in the WSDL document are not being represented
// in this file. They are either aliases[@] of other types represented or were referred
// to but never[!] declared in the document. The types from the latter category
// typically map to predefined/known XML or Borland types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:int - "http://www.w3.org/2001/XMLSchema"
// !:string - "http://www.w3.org/2001/XMLSchema"

// ************************************************************************ //
// Namespace : http://server
// transport : http://schemas.xmlsoap.org/soap/http
// style : document
// binding : mywebserviceHttpBinding
// service : mywebservice
// port : mywebserviceHttpPort
// URL : http://localhost:8080/mywebservice/services/mywebservice
// ************************************************************************ //
mywebservicePortType = interface(IInvokable)
['{56F18980-71B1-FAC0-BFF5-569F621A8591}']
function add(const a: Integer; const b: Integer): Integer; stdcall;
function sayHello(const name: WideString): WideString; stdcall;
end;

function GetmywebservicePortType(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): mywebservicePortType;

implementation

function GetmywebservicePortType(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): mywebservicePortType;
const
defWSDL = 'http://localhost:8080/mywebservice/services/mywebservice?wsdl';
defURL = 'http://localhost:8080/mywebservice/services/mywebservice';
defSvc = 'mywebservice';
defPrt = 'mywebserviceHttpPort';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
RIO := THTTPRIO.Create(nil)
else
RIO := HTTPRIO;
try
Result := (RIO as mywebservicePortType);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;

initialization
InvRegistry.RegisterInterface(TypeInfo(mywebservicePortType), 'http://server', 'UTF-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(mywebservicePortType), '');
InvRegistry.RegisterInvokeOptions(TypeInfo(mywebservicePortType), ioDocument);
InvRegistry.RegisterExternalParamName(TypeInfo(mywebservicePortType), 'add', 'out_', 'out');
InvRegistry.RegisterExternalParamName(TypeInfo(mywebservicePortType), 'sayHello', 'out_', 'out');

end.

3.

新建一个form窗体,拖入一个Button和一个edit控件。
在窗体的uses部分加入InvokeRegistry, Rio, SOAPHTTPClient, mywebservice。
为Button添加click事件。
Java代码 收藏代码
procedure TForm1.Button1Click(Sender: TObject);
var
server:mywebservicePortType;//此处为delphi生成的java-webservice的方法名。
aa:string;
begin
server:=GetmywebservicePortType(true,'',nil);//delphi生成的方法
showmessage(server.sayHello(Edit1.Text));//调用java-webservice的sayHello()方法。
end;

到此,delphi调用java的webservice服务器端程序示例已经完成。

delphi7编写客户端调用java服务器端webservice示例的更多相关文章

  1. .net 客户端调用java或.net webservice进行soapheader验证

    .net 客户端调用java或.net webservice进行soapheader验证 最近项目中有业务需要跨平台调用web服务,客户端和服务器之间采用非对称加密来保证数据的安全性,webservi ...

  2. Java与WCF交互(二):WCF客户端调用Java web service【转】

    原文:http://www.cnblogs.com/downmoon/archive/2010/08/25/1807982.html 在上篇< Java与WCF交互(一):Java客户端调用WC ...

  3. .NET调用JAVA的WebService方法

    调用WebService,最简单的办法当然是直接添加WEB引用,然后自动产生代理类,但是在调用JAVA的WebService时并没有这么简单,特别是对于SoapHeader的处理,在网上也有相关资料, ...

  4. 转载——Java与WCF交互(二):WCF客户端调用Java Web Service

    在上篇< Java与WCF交互(一):Java客户端调用WCF服务>中,我介绍了自己如何使用axis2生成java客户端的悲惨经历.有同学问起使用什么协议,经初步验证,发现只有wsHttp ...

  5. Delphi动态调用Java的WebService 转

    Delphi动态调用Java的WebService —— 基于“Axis2发布WebService例子(HelloWorld)” uses ComObj; var WsObject: Variant; ...

  6. C#调用Java的WebService添加SOAPHeader验证(2)

    C#调用Java的WebService添加SOAPHeader验证 上一篇链接如上,更像是 Net下采用GET/POST/SOAP方式动态调用WebService的简易灵活方法(C#) 来处理xml, ...

  7. C#调用Java的WebService添加SOAPHeader验证

    C#调用Java的WebService添加SOAPHeader验证(2) 1.问题描述 调用的Java的webservice string Invoke(string func, string req ...

  8. Delphi调用JAVA的WebService上传XML文件(XE10.2+WIN764)

    相关资料:1.http://blog.csdn.net/luojianfeng/article/details/512198902.http://blog.csdn.net/avsuper/artic ...

  9. Java客户端调用.NET的WebService

    项目需要去调用.NET的WebSrevice,本身是Java,研究了半天,终于有些头绪,记下来. 1,新建.NET WebService.只在原方法上加上一个string类型的参数str [WebMe ...

随机推荐

  1. Demon_游戏登录界面(具备账号密码输入功能)

    using UnityEngine; using System.Collections; using UnityEngine.UI;// public class LoginButton : Mono ...

  2. 集群中几种session同步解决方案的比较

    1. 客户端cookie加密 .比较好的方法是自己采用cookie机制来实现一个session,在应用中使用此session实现. 问题:session中数据不能太多,最好只有个用户id. Sessi ...

  3. hdu 4499 Cannon(暴力)

    题目链接:hdu 4499 Cannon 题目大意:给出一个n*m的棋盘,上面已经存在了k个棋子,给出棋子的位置,然后求能够在这种棋盘上放多少个炮,要求后放置上去的炮相互之间不能攻击. 解题思路:枚举 ...

  4. How to Read, Write XLSX File in Java - Apach POI Example---reference

    No matter how Microsoft is doing in comparison with Google, Microsoft Office is still the most used ...

  5. Chapter 1. Introduction gradle介绍

      We would like to introduce Gradle to you, a build system that we think is a quantum leap for build ...

  6. Nginx环境下常见的开源项目重写汇总

    我们做PHP开发的,作者寒冰我觉得大部分时候都在跟开源的系统打交道.比如:Discuz.PHPCMS.ecshop.wordpress等开源系统.一般我们都是在本地搭建测试环境,用的web服务器都是a ...

  7. linux学习笔记<命令介绍>

    主要介绍日常工作中一些常用的命令,内容均整理自慕课网 命令提示符 [root@hgs ~]# 其中: root : 当前登录用户 hgs : 主机名 ~ : 当前所在目录(家目录),对于root用户, ...

  8. 网页上facebook分享功能的具体实现

    1,一个链接: 参数是要分享的页面的链接 代码如下: <a style="width:35px; height:40px; position:relative; top:10px; l ...

  9. Objective-C 笔记 字符串操作

    这次总结下OC里一些对字符串的一些操作. 创建字符串对象时,会创建一个内容不可更改的对象,称为不可变对象.可以使用NSString类处理不可变字符串.你经常需要处理字符串并更改字符串中的字符.例如,可 ...

  10. ASP.NET c#学习经验

    1.DataGrid自定义字段.<Column  <asp:BoundColumn DataField="khbh" HeaderText="客户编号&quo ...