delphi客户端调服务器端的java webservice如何在参数中传对象? 转
我试过java返回一个对象到delphi端没问题,可反过来,delphi通过参数传一个对象到java,java端得到的对象值变为空,不知道是不是delphi这边设置或者对象注册方面有问题,究竟该怎么解决,请各位大虾指教,小妹在这多谢各位了!
delphi根据java wsdl文件生成的webservice文件内容如下:
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://10.3.8.92:8080/Service/ws/IFC?wsdl
// Encoding : UTF-8
// Codegen : [wfDebug,wfServer,wfAmbiguousComplexTypesAsArray,wfOutputLiteralTypes,wfIgnoreSchemaErrors,wfUseSerializerClassForAttrs]
// Version : 1.0
// (2009-4-19 10:36:15 - 1.33.2.5)
// ************************************************************************ //
unit IFC;
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.
// ************************************************************************ //
// !:string - "http://www.w3.org/2001/XMLSchema"
// !:dateTime - "http://www.w3.org/2001/XMLSchema"
// !:int - "http://www.w3.org/2001/XMLSchema"
// !:decimal - "http://www.w3.org/2001/XMLSchema"
// !:boolean - "http://www.w3.org/2001/XMLSchema"
Test = class; { "http://xxx.xxx.xxx.com" }
// ************************************************************************ //
// Namespace : http://http://xxx.xxx.xxx.com
// Serializtn: [xoLiteralParam]
// ************************************************************************ //
Test = class(TRemotable)
private
Fuser: WideString;
public
constructor Create; override;
published
property user: WideString read Fuser write Fuser;
end;
// ************************************************************************ //
// Namespace : http://remote.interfaces.xxx.xxx.com
// transport : http://schemas.xmlsoap.org/soap/http
// style : rpc
// binding : IFCHttpBinding
// service : IFC
// port : IFCHttpPort
// URL : http://10.3.8.92:8080/Service/ws/IFC
// ************************************************************************ //
IFCPortType = interface(IInvokable)
['{952A77FA-0414-2644-C2D3-FB6469EE208A}']
function TestB(const in0: Test): WideString; stdcall;
implementation
type
IFCPortTypeImpl = class(TInvokableClass, IFCPortType)
public
{ IFCPortType }
function TestB(const in0: Test): WideString; stdcall;
function IFCPortTypeImpl.TestB(const in0: Test): WideString;
begin
{ TODO - Implement method TestB }
end;
constructor Test.Create;
begin
inherited Create;
FSerializationOptions := [xoLiteralParam];
end;
initialization
InvRegistry.RegisterInterface(TypeInfo(IFCPortType), 'http://remote.interfaces.pastoral.shiji.com', 'UTF-8');
InvRegistry.RegisterInvokableClass(IFCPortTypeImpl);
nvRegistry.RegisterDefaultSOAPAction(TypeInfo(IFCPortType), '');
RemClassRegistry.RegisterXSClass(Test, 'http://entity.pastoral.shiji.com', 'Test');
RemClassRegistry.RegisterSerializeOptions(Test, [xoLiteralParam]);
end;
------解决方案--------------------
在Unit IFC中的initialization 处加以下这句话!
Delphi(Pascal) code
InvRegistry.RegisterInvokeOptions(TypeInfo(IFCPortType), ioDocument);
------解决方案--------------------
个人建议,全部由XML格式代替对象,这才“通用”
2种语言,在沟通上,最好需要有个“介质”我个人觉得 字符串和 XML 是最好的选择,虽然稍微麻烦了一些,但是,绝对不出错!
------解决方案--------------------
问题4:服务端得到的参数都为空值
解决:检查一下引入的WebService单元的最后三行是否如下
initialization
InvRegistry.RegisterInterface(TypeInfo(YourWebServiceSoap), 'http://tempuri.org/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(YourWebServiceSoap), 'http://tempuri.org/%operationName%');
InvRegistry.RegisterInvokeOptions(TypeInfo(YourWebServiceSoap), ioDocument);//这一行有时会没有
end.
这一行 InvRegistry.RegisterInvokeOptions(TypeInfo(YourWebServiceSoap), ioDocument);有时候没有的。举个例子,当我们的WebService的其中一个方法有参数的类型为DataSet时,单元文件的最后几行是这样的
initialization
InvRegistry.RegisterInterface(TypeInfo(YourWebServiceSoap), 'http://tempuri.org/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(YourWebServiceSoap), 'http://tempuri.org/%operationName%');
RemClassRegistry.RegisterXSClass(GetDataSetResult, 'http://tempuri.org/', GetDataSetResult);
RemClassRegistry.RegisterXSClass(updateSet, 'http://tempuri.org/', 'updateSet');
end.
这时,服务端接收到的所有参数都为null;这里你所手工在中间加入上面所提到的那一行。
------解决方案--------------------
虽然我不大懂,但是也要说一句:
首先,To: Cnapollo :WebService传递对象的本质就是传递XML文本
难道你真的以为WebService传递的是序列化了的对象?
其次要说的是:java的WebService中的命名空间的问题
从你上面的WSDL文件来看,命名空间应该是:http://tempuri.org/
这个是默认的命名空间,一般在真正开发的时候会修改,java中最后的命名空间实际上就是服务器类所在的包
我以前用java写过WebService的简单例子,即使客户端用java来写,如果客户端包的位置(也就是命名空间)和服务器
不一致的话,那么,也会出现对象为空,或者访问了没任何返回的情况。
Delphi中好像没有包这个说法,我也不知道如何将Delphi中的命名空间修改。
但是建议你修改initialization 下面的凡是引用到命名空间的地方。让他和服务器的命名空间一致。
服务器的命名空间应该在服务器的WSDL文件中找的到。
再加上上面几位高手的方法或许就成功了呢!
另外,D7的WebService服务器被客户端调用的时候,又一些BUG。
比如:时间类型的数据的转化,NTDLL.DLL的错误,这些需要修改D7部分单元的代码,在重新编译。
我所知道的就这些。
delphi客户端调服务器端的java webservice如何在参数中传对象? 转的更多相关文章
- 【java】之对List中每个对象元素按时间顺序排序
import java.text.SimpleDateFormat; import java.util.*; public class ListSort { public static class U ...
- Java Servlet(三):Servlet中ServletConfig对象和ServletContext对象
本文将记录ServletConfig/ServletContext中提供了哪些方法,及方法的用法. ServletConfig是一个抽象接口,它是由Servlet容器使用,在一个servlet对象初始 ...
- java使用ObjectInputStream从文件中读取对象
import java.io.EOFException;import java.io.FileInputStream;import java.io.FileNotFoundException;impo ...
- java 发送post请求参数中含有+会转化为空格的问题
如题 原因分析:参数在传递过程中经历的几次编码和解码标准不同,导致加号.空格等字符的错误. 解决方案:将post请求的参数中 ,含有+号的,统统采用%2B 去替换,这是URL的协议问题.
- ASP.NET获取客户端、服务器端的信息
ASP.NET获取客户端.服务器端基础信息 1. 在ASP.NET中专用属性: 获取服务器电脑名:Page.Server.ManchineName 获取用户信息:Page.User 获取客户端电脑名: ...
- java网络编程,简单的客户端和服务器端
1.服务器端 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import ...
- gRPC java 客户端,服务器端通讯使用json格式
使用 protobuf 作为通讯内容序列化的简单例子请看:http://www.cnblogs.com/ghj1976/p/5458176.html . 本文是使用 json 做为内容序列化的简单例子 ...
- 浅析Java web程序之客户端和服务器端交互原理(转)
转载自http://www.cnblogs.com/lys_013/archive/2012/05/05/2484561.html 1. 协议 a. TCP/IP整体构架概述 TCP/IP协议并不完全 ...
- phprpc 使用实例(同时有Java、Android和Delphi客户端的例子)
PHPRPC 是一个轻型的.安全的.跨网际的.跨语言的.跨平台的.跨环境的.跨域的.支持复杂对象传输的.支持引用参数传递的.支持内容输出重定向的.支持分级错误处理的.支持会话的.面向服务的高性能远程过 ...
随机推荐
- 模型类中 Parcelable 接口使用
package com.exmyth.ui.model; import java.util.ArrayList; import java.util.List; public class Product ...
- Zend Studio 10正式版破解(2013-02-26更新)
Zend Studio 10正式版注册破解(2013-02-26完成更新) 1.以下方法仅供技术交流学习,请勿非法使用,如长期使用请支持购买正版. 2.若你还没有最新安装程序? ZendStudio ...
- 单页面应用SPA架构
个人认为单页面应用的优势相当明显: 前后端职责分离,架构清晰:前端进行交互逻辑,后端负责数据处理. 前后端单独开发.单独测试. 良好的交互体验,前端进行的是局部渲染.避免了不必要的跳转和重复渲染. 当 ...
- Java基础知识强化93:算一下你来到这个世界多少天的案例
1. 分析: (1)键盘录入你的出生年月日 (2)把该字符串转换为一个日期 (3)通过该日期得到一个毫秒值 (4)获取当前时间的毫秒值 (5)用(4)-(3)得到一个毫秒值 (6)把E的毫秒值转换为天 ...
- Java基础知识强化82:Random类概述和方法使用
1. Random类 public class Random extends Object implements Serializable: 此类的实例用于生成伪随机数流.此类使用48位种子. (1) ...
- 怎么在Linux上下载并安装ESET NOD32 Antivirus 4桌面版
转自:怎么在Linux上下载并安装ESET NOD32 Antivirus 4桌面版 下载并安装ESET NOD32 Antivirus 4的Linux桌面版,根据下面的步骤一步一步的来: I. 下 ...
- HTML 控件和web控件 OnClientClick和OnClick OnServerClick区别
^_^ 本来对html控件,服务器控件的知识模模糊糊的.今天特地查了相关的知识. 下面是我写代码总结的. 这些事件 主要用于在客户端执行验证,然后决定是否执行服务端事件 (没接触之前就为此 ...
- Android Http请求失败解决方法
1.MainActivity.java 文件中的onCreate方法改成如下: @SuppressLint("NewApi") @Override protected void o ...
- MySQL导入导出命令
前言 如果使用图形化界面,那么可以通过几个点击即可导入.导出.本文是假定你没有安装那些如Navicat等GUI管理软件. 场景 假设在电脑A和电脑B中都装有MySQL数据库管理系统,并且在电脑A的My ...
- spring 配置触发器 (类似于定时任务)
为什么会看这个? 发现项目中有的service中的方法没有地方调用.经查,发现在web.xml中加载的spring的配置文件中配置了这个方法, 经查这种方式是触发器,会定时执行,只需要配置一下.可以设 ...