Java论坛网»Java技术»有关webservice非基本类型数据传递的问题,有兴趣的请进,谢谢。

有关webservice非基本类型数据传递的问题,有兴趣的请进,谢谢。

问?:
最近有个项目决定采用webservice,服务器端采用Java,客户端采用delphi.
但是如果服务器端的复杂类型比如ResultSet传递到客户端的话,delphi中没有办法解析ResultSet,
现在我考虑到有两种可能解决方案,但是我都没有想通,由于不熟悉,望大虾们帮帮小弟:
(1)采用WSDL中自定义类型来定义ResultSet,不知道这样定义行不行?如果行的话不知道该如何定义ResultSet;
(2)将Java中的ResultSet解析成一定格式的xml文件,然后客户端解析该xml文件,但是用Jdom解析的话,好像两个xml文件格式不一致,
麻烦哪位达人帮我分析分析,感激不尽。~~
答!: 1:
我们以前这样做过。

首先用xml传递数据是正确的,不能用自定义类型,因为delphi不认识。
其次确实需要把java的resultset产生的xml和delphi的CDS需要的xml格式之间进行转换,转换的方式可以用XSLT。
答!: 2:
好的,我试一下。多谢。
答!: 3:
infowain(infowain),您好,非常谢谢您能帮我分析该问题。
可是我对XSLT转换两个不同格式的xml文件的实现方式不熟悉,用google搜索了一下相关内容也不能找到解决方案,能不能再麻烦您告诉我一下转换的具体思路?谢谢。
例如,我要将a.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
- <xhtml:result xmlns:xhtml="http://w3.org/etc">
- <xhtml:entry some4="Sales Representative">
<xhtml:EmployeeID>1</xhtml:EmployeeID>
<xhtml:LastName>Davolio</xhtml:LastName>
<xhtml:num3>Nancy</xhtml:num3>
<xhtml:TitleOfCourtesy>Ms.</xhtml:TitleOfCourtesy>
<xhtml:BirthDate>1948年12月8日 星期三 上午12时00分00秒 CST</xhtml:BirthDate>
<xhtml:HireDate>1992年5月1日 星期五 上午12时00分00秒 CST</xhtml:HireDate>
<xhtml:Address>507 - 20th Ave. E. Apt. 2A</xhtml:Address>
<xhtml:City>Seattle</xhtml:City>
<xhtml:Region>WA</xhtml:Region>
<xhtml:PostalCode>98122</xhtml:PostalCode>
<xhtml:Country>USA</xhtml:Country>
<xhtml:HomePhone>(206) 555-9857</xhtml:HomePhone>
<xhtml:Extension>5467</xhtml:Extension>
<xhtml:Notes>Education includes a BA in psychology from Colorado State University in 1970. She also completed "The Art of the Cold Call." Nancy is a member of Toastmasters International.</xhtml:Notes>
<xhtml:ReportsTo>2</xhtml:ReportsTo>
<xhtml:PhotoPath>http://accweb/emmployees/davolio.bmp</xhtml:PhotoPath>
</xhtml:entry>
</xhtml:result>
转换为b.xml文件
<?xml version="1.0" standalone="yes"?>
<DATAPACKET Version="2.0">
<METADATA>
<FIELDS>
<FIELD attrname="EmployeeID" fieldtype="i4" readonly="true" SUBTYPE="Autoinc"/>
<FIELD attrname="LastName" fieldtype="string.uni" WIDTH="40"/>
<FIELD attrname="FirstName" fieldtype="string.uni" WIDTH="20"/>
<FIELD attrname="Title" fieldtype="string.uni" WIDTH="60"/>
<FIELD attrname="TitleOfCourtesy" fieldtype="string.uni" WIDTH="50"/>
<FIELD attrname="BirthDate" fieldtype="dateTime"/>
<FIELD attrname="HireDate" fieldtype="dateTime"/>
<FIELD attrname="Address" fieldtype="string.uni" WIDTH="120"/>
<FIELD attrname="City" fieldtype="string.uni" WIDTH="30"/>
<FIELD attrname="Region" fieldtype="string.uni" WIDTH="30"/>
<FIELD attrname="PostalCode" fieldtype="string.uni" WIDTH="20"/>
<FIELD attrname="Country" fieldtype="string.uni" WIDTH="30"/>
<FIELD attrname="HomePhone" fieldtype="string.uni" WIDTH="48"/>
<FIELD attrname="Extension" fieldtype="string.uni" WIDTH="8"/>
<FIELD attrname="Notes" fieldtype="bin.hex" SUBTYPE="Text"/>
<FIELD attrname="ReportsTo" fieldtype="i4"/>
<FIELD attrname="PhotoPath" fieldtype="string.uni" WIDTH="510"/>
</FIELDS>
<PARAMS/>
</METADATA>
<ROWDATA>
<ROW EmployeeID="1" LastName="Davolio" FirstName="Nancy" Title="Sales Representative" TitleOfCourtesy="Ms." BirthDate="19481208" HireDate="19920501" Address="507 - 20th Ave. E.&#013;&#010;Apt. 2A" City="Seattle" Region="WA" PostalCode="98122" Country="USA" HomePhone="(206) 555-9857" Extension="5467" Notes="Education includes a BA in psychology from Colorado State University in 1970. She also completed &quot;The Art of the Cold Call.&quot; Nancy is a member of Toastmasters International." ReportsTo="2" PhotoPath="http://accweb/emmployees/davolio.bmp"/>
</ROWDATA>
</DATAPACKET>

答!: 4:
两个xml文件进行转换时,如果有图片之类的block数据,两个xml文件编码不一样,通过xslt转换后还能正确识别吗?谢谢
答!: 5:
对于图片之类的数据,你可以用CDATA

相关JAVA教程:
struts <html:select property="myselect" multiple="true"> 对应 formbean 里myselect属性应该是什?
(急)服务器带宽在10M/s,同时大概能支撑多少用户访问?
怎样在JAVA里面用返回参数的存储过程
急,struts Formbean 验证问题
WEB SERVICE 在TOMCAT上能运行,ORACLE AS不能运行的问题
求助:Hibernate,空指针错误
请教一个Hibernate的AssertionFailure问题
weblogic上连接ms sql连接池错误
求助---加载图片时怎样设置路径?
跨页面的事务问题
求助---加载图片时怎样设置路径?
请各位大侠指点一下,数据连接的问题!