求助:delphi7调用java写的webservice(axis2)出现的问题

Bruce 2007-09-04 05:53:22
我的程序是delphi7写的客户端,需要调用java写的webservice服务,用了axis2,jdk1.5,tomcat5.5
webservice写了一个简单的测试方法为:
==========
public String getName(String name){
return "Hello "+name;
}
==========
wsdl完整代码为:
=========
- <wsdl:definitions xmlns:axis2="http://print.license.webservice.jscb" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ns0="http://print.license.webservice.jscb/xsd" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://print.license.webservice.jscb">
<wsdl:documentation>This service is to process the remote data</wsdl:documentation>
- <wsdl:types>
- <xs:schema xmlns:ns="http://print.license.webservice.jscb/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://print.license.webservice.jscb/xsd">
- <xs:element name="saveScores">
- <xs:complexType>
- <xs:sequence>
<xs:element name="examType" nillable="true" type="xs:string" />
<xs:element name="paperNo" nillable="true" type="xs:string" />
<xs:element maxOccurs="unbounded" name="adminNo" nillable="true" type="xs:string" />
<xs:element maxOccurs="unbounded" name="answers" nillable="true" type="xs:string" />
<xs:element maxOccurs="unbounded" name="scores" nillable="true" type="xs:int" />
<xs:element maxOccurs="unbounded" name="ispass" nillable="true" type="xs:boolean" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="saveScoresResponse">
- <xs:complexType>
- <xs:sequence>
<xs:element name="return" nillable="true" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="getName">
- <xs:complexType>
- <xs:sequence>
<xs:element name="name" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="getNameResponse">
- <xs:complexType>
- <xs:sequence>
<xs:element name="return" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="getDataList">
- <xs:complexType>
- <xs:sequence>
<xs:element name="sqlStr" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="getDataListResponse">
- <xs:complexType>
- <xs:sequence>
<xs:element maxOccurs="unbounded" name="return" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
- <wsdl:message name="getNameMessage">
<wsdl:part name="part1" element="ns0:getName" />
</wsdl:message>
- <wsdl:message name="getNameResponse">
<wsdl:part name="part1" element="ns0:getNameResponse" />
</wsdl:message>
- <wsdl:message name="getDataListMessage">
<wsdl:part name="part1" element="ns0:getDataList" />
</wsdl:message>
- <wsdl:message name="getDataListResponse">
<wsdl:part name="part1" element="ns0:getDataListResponse" />
</wsdl:message>
- <wsdl:message name="saveScoresMessage">
<wsdl:part name="part1" element="ns0:saveScores" />
</wsdl:message>
- <wsdl:message name="saveScoresResponse">
<wsdl:part name="part1" element="ns0:saveScoresResponse" />
</wsdl:message>
- <wsdl:portType name="ExamServicePortType">
- <wsdl:operation name="getName">
<wsdl:input xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" message="axis2:getNameMessage" wsaw:Action="urn:getName" />
<wsdl:output message="axis2:getNameResponse" />
</wsdl:operation>
- <wsdl:operation name="getDataList">
<wsdl:input xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" message="axis2:getDataListMessage" wsaw:Action="urn:getDataList" />
<wsdl:output message="axis2:getDataListResponse" />
</wsdl:operation>
- <wsdl:operation name="saveScores">
<wsdl:input xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" message="axis2:saveScoresMessage" wsaw:Action="urn:saveScores" />
<wsdl:output message="axis2:saveScoresResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="ExamServiceSOAP11Binding" type="axis2:ExamServicePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <wsdl:operation name="getName">
<soap:operation soapAction="urn:getName" style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="getDataList">
<soap:operation soapAction="urn:getDataList" style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="saveScores">
<soap:operation soapAction="urn:saveScores" style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name="ExamServiceSOAP12Binding" type="axis2:ExamServicePortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
- <wsdl:operation name="getName">
<soap12:operation soapAction="urn:getName" style="document" />
- <wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="getDataList">
<soap12:operation soapAction="urn:getDataList" style="document" />
- <wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="saveScores">
<soap12:operation soapAction="urn:saveScores" style="document" />
- <wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name="ExamServiceHttpBinding" type="axis2:ExamServicePortType">
<http:binding verb="POST" />
- <wsdl:operation name="getName">
<http:operation location="getName" />
- <wsdl:input>
<mime:content type="text/xml" />
</wsdl:input>
- <wsdl:output>
<mime:content type="text/xml" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="getDataList">
<http:operation location="getDataList" />
- <wsdl:input>
<mime:content type="text/xml" />
</wsdl:input>
- <wsdl:output>
<mime:content type="text/xml" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="saveScores">
<http:operation location="saveScores" />
- <wsdl:input>
<mime:content type="text/xml" />
</wsdl:input>
- <wsdl:output>
<mime:content type="text/xml" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="ExamService">
- <wsdl:port name="ExamServiceSOAP11port_http" binding="axis2:ExamServiceSOAP11Binding">
<soap:address location="http://192.168.1.31:8080/jscbmis/services/ExamService" />
</wsdl:port>
- <wsdl:port name="ExamServiceSOAP12port_http" binding="axis2:ExamServiceSOAP12Binding">
<soap12:address location="http://192.168.1.31:8080/jscbmis/services/ExamService" />
</wsdl:port>
- <wsdl:port name="ExamServiceHttpport" binding="axis2:ExamServiceHttpBinding">
<http:address location="http://192.168.1.31:8080/jscbmis/services/ExamService" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
=============================
由于输入字数限制我在下面回帖中继续
...全文
642 21 打赏 收藏 转发到动态 举报
写回复
用AI写文章
21 条回复
切换为时间正序
请发表友善的回复…
发表回复
heihei122 2012-10-18
  • 打赏
  • 举报
回复
InvRegistry.RegisterInterface(TypeInfo(IRemoteDataService),'http://localhost:8080/jscbmis/services/ExamService', 'utf-8');

中的'http://localhost:8080/jscbmis/services/ExamService' 修改成java端报错时的

'http://print.license.webservice.jscb/xsd' 试试看 应该可以了
heihei122 2012-10-15
  • 打赏
  • 举报
回复
我也遇到了 这个问题 有没有人指导下呀 十分感谢 困扰好几天了
山东蓝鸟贵薪 2012-10-15
  • 打赏
  • 举报
回复
帮顶帖子中
不好意思,没有研究
coolben 2011-09-22
  • 打赏
  • 举报
回复
救命的干活
Paradin 2010-04-27
  • 打赏
  • 举报
回复
mark..
starluck 2009-11-24
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 wzwcn 的回复:]
不知道你的Delphi是什么版本,以前我用D7调网上一个天气预报Webservice(.net)的一直不成功,改成D2007重新导入WSDL,再调用就成功了,不知道什么原因,可能D7后SOAP协议有所修改。
你的代码可以这样调再试试:

引用生成的单元
procedure TmainForm.BtnSaveDBClick(Sender: TObject);
var
  soaptemp:IRemoteDataService;
begin
  soaptemp := GetIRemoteDataService;
  showmessage(soaptemp.getName('bruce'));
end;

[/Quote]


不是不成功,而是DELPHI7导出的少注册了东西.
wzwcn 2009-11-24
  • 打赏
  • 举报
回复
不知道你的Delphi是什么版本,以前我用D7调网上一个天气预报Webservice(.net)的一直不成功,改成D2007重新导入WSDL,再调用就成功了,不知道什么原因,可能D7后SOAP协议有所修改。
你的代码可以这样调再试试:

引用生成的单元
procedure TmainForm.BtnSaveDBClick(Sender: TObject);
var
soaptemp:IRemoteDataService;
begin
soaptemp := GetIRemoteDataService;
showmessage(soaptemp.getName('bruce'));
end;
jerryelva 2009-11-24
  • 打赏
  • 举报
回复
今天遇到跟楼主一样的问题,
我这个问题是由于http://service.ws.tmri.com这个没有正确,后来设置成正确的行了。com.tmri.ws.service就是web services服务类包名。

InvRegistry.RegisterInterface(TypeInfo(Veh), 'http://service.ws.tmri.com', 'UTF-8');
helodd 2008-05-24
  • 打赏
  • 举报
回复
暈,D2005後面的版本調用java,.net的Web Services 都比較麻煩。換D2005就好了。
wts 2008-05-23
  • 打赏
  • 举报
回复
天啊,我也遇到这样的问题了,研究一天了也没解决,楼主解决了吗?
hongqi162 2007-09-05
  • 打赏
  • 举报
回复
问题就在这里你确定http://localhost:8080/jscbmis/services/ExamService 是你的Namespace?


InvRegistry.RegisterInterface(TypeInfo(IRemoteDataService), 'http://localhost:8080/jscbmis/services/ExamService ', 'utf-8 ');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(IRemoteDataService), 'http://localhost:8080/jscbmis/services/ExamService/%operationName% ');
Bruce 2007-09-05
  • 打赏
  • 举报
回复
能帮我看一下引入wsdl的代码那块写的有什么问题吗?
Bruce 2007-09-05
  • 打赏
  • 举报
回复
不行啊,报一样的错误。这个WSDLLocation我在HTTPRIO1控件中设置了。
Bruce 2007-09-05
  • 打赏
  • 举报
回复
好的,我试一下
hongqi162 2007-09-05
  • 打赏
  • 举报
回复
procedure TmainForm.BtnSaveDBClick(Sender: TObject);
var
soaptemp:IRemoteDataService;
begin
soaptemp := HTTPRIO1 as IRemoteDataService;
soaptemp.WSDLLocation:= 'http://localhost:8080/jscbmis/services/ExamService?WSDL';
showmessage(soaptemp.getName( 'bruce '));
end;
Bruce 2007-09-05
  • 打赏
  • 举报
回复
怎么没人来看?顶上来
hongqi162 2007-09-05
  • 打赏
  • 举报
回复
我用delphi做过调用java webservice的东西,这个是我导入WSDL的代码



// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : D:\projects\WSDL\Veh.wsdl.xml
// Encoding : UTF-8
// Version : 1.0
// (2007-7-9 10:06:50 - 1.33.2.5)
// ************************************************************************ //

unit ImplVeh;

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"
// !:int - "http://www.w3.org/2001/XMLSchema"
// !:long - "http://www.w3.org/2001/XMLSchema"



// ************************************************************************ //
// Namespace : http://service.ws.tmri.com
// transport : http://schemas.xmlsoap.org/soap/http
// style : document
// binding : VehSoapBinding
// service : VehService
// port : Veh
// URL : http://10.160.118.40:9080/ServicePlatform/services/Veh
// ************************************************************************ //
Veh = interface(IInvokable)
['{032969C0-190F-A5B1-F79D-17283635E2AC}']
function getVehWorkPart(const hpzl: WideString; const hphm: WideString; const sn: WideString): WideString; stdcall;
function getVehWorkFull(const hpzl: WideString; const hphm: WideString; const sn: WideString): WideString; stdcall;
function write_vehicle_zt(const hpzl: WideString; const hphm: WideString; const zt: WideString; const bj: Integer; const sn: WideString): WideString; stdcall;
function wrtie_vehcheckmid(const hpzl: WideString; const hphm: WideString; const clsbdh: WideString; const jyjg: WideString; const jyrq: WideString; const cjdw: WideString; const sn: WideString): WideString; stdcall;
function getVehQueryFull(const hpzl: WideString; const hphm: WideString; const sn: WideString): WideString; stdcall;
function write_vehicle_hphm_sn(const hpzl: WideString; const hphm: WideString; const jbr: WideString; const sn: WideString): WideString; stdcall;
function getVehFlow(const glbm: WideString; const xygw: WideString; const sn: WideString): WideString; stdcall;
function getVehQueryPart(const hpzl: WideString; const hphm: WideString; const sn: WideString): WideString; stdcall;
function getVehimage(const hpzl: WideString; const hphm: WideString; const sn: WideString): WideString; stdcall;
function write_vehimage(const hpzl: WideString; const hphm: WideString; const zp: WideString; const sn: WideString): WideString; stdcall;
function write_bxxx(const hpzl: WideString; const hphm: WideString; const clsbdh: WideString; const bxpzh: WideString; const bxje: Int64; const sxrq: WideString; const zzrq: WideString; const bxgs: WideString; const sn: WideString): WideString; stdcall;
end;

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


implementation

function GetVeh(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): Veh;
const
defWSDL = 'D:\projects\WSDL\Veh.wsdl.xml';
defURL = 'http://10.160.118.40:9080/ServicePlatform/services/Veh';
defSvc = 'VehService';
defPrt = 'Veh';
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 Veh);
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(Veh), 'http://service.ws.tmri.com', 'UTF-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(Veh), '');
InvRegistry.RegisterInvokeOptions(TypeInfo(Veh), ioLiteral);
end.
Bruce 2007-09-05
  • 打赏
  • 举报
回复
人气不旺,问题解决不了。决定换语言写客户端。
Bruce 2007-09-05
  • 打赏
  • 举报
回复
感谢你的建议,这两行代码我调试N次了,空串,类里的命名空间,还有WSDL里的namespace我都试过,这个是我最后一次调试时候加上的。可是这里的字符串不管换成什么程序还是那样执行,没有任何不同,就好像这里写的东西不起作用一样,都是一律报命名空间不匹配。这个错误是在服务器端报的。
应该说明我的请求已经发到了服务端,但是服务端无法解析我的命名空间不知道是什么道理。
还有什么建议?
Bruce 2007-09-04
  • 打赏
  • 举报
回复
有谁能有解决方法或者有类似的例子,联系我/mail均可:msn:wskwmj@msn.com
加载更多回复(1)
目 录 1 文档介绍.......................................................................................................................................3 1.1 文档概述.............................................................................................................................3 1.2 适用范围.............................................................................................................................3 2 环境描述.......................................................................................................................................3 3 配置 EOS的 WebService服务....................................................................................................3 3.1 配置 WebService 声明.......................................................................................................3 3.1.1 WebLogic8.x环境.....................................................................................................3 3.1.2 JBoss 环境.................................................................................................................4 3.1.3 WebSphere5.x 环境...................................................................................................4 3.2 加入 axis 的 jar包到 CLASSPATH...................................................................................4 3.2.1 WebLogic8.x环境.....................................................................................................4 3.2.2 JBoss 环境.................................................................................................................5 3.2.3 WebSphere5.x 环境...................................................................................................5 3.3 设置调用 WebService 的验证码........................................................................................5 4 验证 EOS的 WebService服务....................................................................................................6 5 如何通过 EOS的 WebService 服务来调用业务逻辑................................................................6 5.1 传统 JAVA 方式.................................................................................................................6 5.1.1 调用方式及说明........................................................................................................6 5.1.2 例子...........................................................................................................................7 5.2 使用 EOS提供的 bizlet 调用方式..................................................................................11 5.2.1 调用方式及说明......................................................................................................11 5.2.2 例子.........................................................................................................................12 5.3 使用 VB 调用方式...........................................................................................................12 5.3.1 例子.........................................................................................................................12 5.4 使用 VC 调用方式...........................................................................................................13 5.4.1 例子.........................................................................................................................13 5.5 使用 delphi调用方式.......................................................................................................15 5.5.1 例子.........................................................................................................................15 附录 1: axis 的 jar包..................................................................................................................16 6 支持............................................................................................................................................18

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧