300分,求delphi调用web service 错误问题(回答正确另加300分)(300分)

  • 主题发起人 主题发起人 忍我
  • 开始时间 开始时间

忍我

Unregistered / Unconfirmed
GUEST, unregistred user!
Project Project1.exe raised exception class EDOMParseError with message 'Only one top level element is allowed in an XML document.
Line: 2
<p>Hi there, this is an AXIS service!</p'. Process stopped. Use Step or Run to continue.
 
代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var
InterfaceVariable: AmrService;
i:integer;
X :THTTPRio;
begin
X := THTTPRio.Create(nil);
// InterfaceVariable:=GetAmrService(true,' ',nil);
X.HTTPWebNode.UseUTF8InHeader := true ;
//WSDLLocation也可以是在本地文件系统中的wsdl文件。
X.WSDLLocation :='http://211.144.32.182:8080/amr/services/AmrService';
// X.WSDLLocation := 'E:/wsdl/AmrService.wsdl';
X.Service := 'AmrServiceService';
X.Port := 'AmrService';
InterfaceVariable := X as AmrService;
i:=InterfaceVariable.getRecentlyVa('000612302759');
self.Label_return_value.Caption:=inttostr(i);
X.free;
end;
 
帮你顶了。。
 
出错信息只是说您的XML文件有多于一个的根结点(这是不合法的),好象与Web Service无关嘛。
 
与什么有关??是与xml文件有关??还是与msxml的版本有关??怎么修改问题??请具体点??
 
使用的XML文档有问题
下面只一个标准的XML文档
<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
<feature primary=&quot;false&quot; provider-name=&quot;%providerName&quot; label=&quot;%featureName&quot; image=&quot;eclipse_update_120.jpg&quot; id=&quot;org.eclipse.pde.source&quot; version=&quot;3.0.1&quot;>
<description >
%description
</description>
<license url=&quot;%licenseURL&quot;>
%license
</license>
<url>
<update label=&quot;%updateSiteName&quot; url=&quot;http://update.eclipse.org/updates/3.0&quot;/>
<discovery label=&quot;%updateSiteName&quot; url=&quot;http://update.eclipse.org/updates/3.0&quot;/>
</url>
<plugin fragment=&quot;false&quot; download-size=&quot;0&quot; install-size=&quot;0&quot; id=&quot;org.eclipse.pde.source&quot; version=&quot;3.0.1&quot;/>
</feature>
 
服务器端返回的xml不合法.
 
请问怎么修改呀??是要修改web service返回的xml吗??
 
请给出详细解决问题答案,马上给分!
 
你用的版本是多少,Delphi7的会好点。这是Web Service的问题。
 
就是delphi7呀!
 
代码也没有,只能看到这里了。您的Web Service的功能?看样子是要取XML文件或是要建XML文件?
 
还有这个导入delphi的wdsl文件:
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : D:/wsdl/AmrService.wsdl
// Encoding : UTF-8
// Version : 1.0
// (2006-6-10 14:37:26 - 1.33.2.5)
// ************************************************************************ //

unit AmrService1;

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 - &quot;http://www.w3.org/2001/XMLSchema&quot;
// !:short - &quot;http://www.w3.org/2001/XMLSchema&quot;

ArrayOf_xsd_string = array of WideString; { &quot;http://t645.server.amr&quot; }

// ************************************************************************ //
// Namespace : http://t645.server.amr
// transport : http://schemas.xmlsoap.org/soap/http
// style : rpc
// binding : AmrServiceSoapBinding
// service : AmrServiceService
// port : AmrService
// URL : http://localhost:8080/amr/services/AmrService
// ************************************************************************ //
AmrService = interface(IInvokable)
['{4A4F6B63-25F9-6463-2788-58D1D21449FD}']
function getRecentlyVa(const equipment_id: WideString): Smallint; stdcall;
function getActiveSpotList: ArrayOf_xsd_string; stdcall;
end;

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


implementation

function GetAmrService(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): AmrService;
const
defWSDL = 'D:/wsdl/AmrService.wsdl';
defURL = 'http://localhost:8080/amr/services/AmrService';
defSvc = 'AmrServiceService';
defPrt = 'AmrService';
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 AmrService);
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(AmrService), 'http://t645.server.amr', 'UTF-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(AmrService), '');
RemClassRegistry.RegisterXSInfo(TypeInfo(ArrayOf_xsd_string), 'http://t645.server.amr', 'ArrayOf_xsd_string');

end.
 
delphi调用web service 代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var
InterfaceVariable: AmrService;
i:integer;
X :THTTPRio;
begin
X := THTTPRio.Create(nil);
// InterfaceVariable:=GetAmrService(true,' ',nil);
X.HTTPWebNode.UseUTF8InHeader := true ;
//WSDLLocation也可以是在本地文件系统中的wsdl文件。
X.WSDLLocation :='http://211.144.32.182:8080/amr/services/AmrService';
// X.WSDLLocation := 'E:/wsdl/AmrService.wsdl';
X.Service := 'AmrServiceService';
X.Port := 'AmrService';
InterfaceVariable := X as AmrService;
i:=InterfaceVariable.getRecentlyVa('000612302759');
self.Label_return_value.Caption:=inttostr(i);
X.free;
end;
 
看代码很烦啊
 
这么多代码是delphi内部的吗?
用ctrl+鼠标进去的吗/
有没有外面的代码啊 这个看着太麻烦了
 
服务器返回的是一个错误页面源码,不是标准XML格式字符串
你可以截获HTTPRIO的SOAPResponse: TStream(在AfterExecute事件中),看看你到底是返回的什么错误。
 
请求高手解决
 

Similar threads

I
回复
0
查看
996
import
I
I
回复
0
查看
2K
import
I
I
回复
0
查看
3K
import
I
I
回复
0
查看
3K
import
I
I
回复
0
查看
853
import
I
后退
顶部