Home > Back-end >  Delphi development WebService, call other WebService error problem
Delphi development WebService, call other WebService error problem

Time:09-20

Background [projects] : to develop a customer local WebService + cloud web service system, the local WebService used to encapsulate the cloud service for the customers, its business parameters, processing to the clouds, and asynchronous notifications customer has its own system,
[technology selection] : local WebService development: 10 Seattle Delphi + IIS deployment; The cloud: Java + Apache deployment, test client: Delphi 10 Seattle,
[development and debugging environment] : local: win10 + IIS10; The cloud: Windows 7 + Java + Tomcat, the local and the clouds are in the same network environment,
Overview [question] : deployment in the IIS service provides two types of interfaces: do not rely on the cloud interface (local interface) and relies on the interface of the cloud, the cloud interface),
Phenomenon 1: test client Access IIS service, local interface is normal, Access interface failure, the clouds hint Access violation at address XXX in the module 'w3wp.exe'. The Execution of address XXX,
Early screening [] :
1: the test client web service's WSDL directly into the clouds, direct access to the cloud service interface, operating normally,
2: using Delphi to create a Stand - u.s program, the function of introducing deployment in IIS unit, to compile a debugging with WebService program running and test client access WebService program debugging, access to the cloud is normal,
3. Modify the local WebService code, gradually thinning,
Introduced using WSDL 3.1 unit provides GetXXX methods, obtain a service object ObjService (success),
3.2 whether ObjService is nil, not to nil,
3.3 call the cloud method using ObjService, abnormal, the exception message for the Access violation at address XXX in the module 'w3wp.exe'. The Execution of address XXX
After the introduction of [the cloud WebService in WSDL code]
 
Type
ServiceTest=interface (IInvokable)
[' {EF9003DD d1a9e47d69 ee - 7741 - A0E6-26-80} ']
The function getValue (const arg0: string) : string; Stdcall;
end;

The function GetServiceTest (UseWSDL: Boolean=System. False. Addr: string='; HTTPRIO: THTTPRIO=nil) : ServiceTest;


Implementation
USES the System. The SysUtils;

The function GetServiceTest (UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO) : ServiceTest;
Const
DefWSDL='http://10.19.128.136:8080/ServiceTest? WSDL ';
DefURL='http://10.19.128.136:8080/ServiceTest'.
DefSvc='ServiceTestService';
DefPrt='ServiceTestPort';
Var
RIO: THTTPRIO;
The begin
Result:=nil;
If (Addr=' ') then
The begin
If UseWSDL then
Addr:=defWSDL
The else
Addr:=defURL;
end;
If HTTPRIO=nil then
RIO:=THTTPRIO. Create (nil)
The else
RIO:=HTTPRIO;
Try
Result:=(RIO as ServiceTest);
If UseWSDL then
The begin
RIO. WSDLLocation:=Addr;
RIO. Service:=defSvc;
RIO. Port:=defPrt;
End the else
LTD URL:=Addr;
The finally
If (Result=nil) and (HTTPRIO=nil) then
RIO. Free;
end;
end;


Initialization
{ServiceTest}
InvRegistry. RegisterInterface (TypeInfo (ServiceTest), 'http://test.servyou.com/', 'utf-8');
InvRegistry. RegisterDefaultSOAPAction (TypeInfo (ServiceTest), ");
InvRegistry. RegisterInvokeOptions (TypeInfo (ServiceTest), ioDocument);
{ServiceTest. GetValue}
InvRegistry. RegisterMethodInfo (TypeInfo (ServiceTest), 'getValue', ' ',
'[ReturnName="return"], IS_OPTN or IS_UNQL);
InvRegistry. RegisterParamInfo (TypeInfo (ServiceTest), 'getValue', 'arg0', ' ',
"', IS_UNQL);
InvRegistry. RegisterParamInfo (TypeInfo (ServiceTest), 'getValue', 'return', ' ',
"', IS_UNQL);

[local WebService calls the cloud WebService of code]
 
The function TDataPreVerify. CloudTest (const arg0: string) : string;
Var
VRet: ServiceTest;
The begin
Try
VRet:=GetServiceTest;
Except,
On e: the Exception do
The begin
Result:=e.M essage.
The Exit;
end;
end;
If vRet=nil then
Result:='remote service is nil'
The else
The begin
Try
Result: vRet.=getValue (arg0);
Except,
On e: the Exception do
The begin
Result:='remote service is normal, interface access exception: + e.M essage.
The Exit;
end;
end;
Result:='test' + Result;//GetServiceTest getValue (arg0);
end;
end;

Client calls the deployment of the above code, test after the IIS service returns "remote service is normal, interface Access exception: the Access violation at address 000001 fc00495c30 module in 'w3wp.exe'. The Execution of address 000001 fc00495c30", can prove that object is created, and is not null, but what is the problem, a method is called
Now there may be some doubt is IIS configuration problem (some configuration to do or don't); Will or win10 not server system, IIS existence insufficiency; Or IIS would not support access to other WebService ability? Because of using Delphi to create Stand - u.s service running, can be normal access to the cloud, and it is the same code, so from the code should be no problem,
Below is the IIS configuration, web. Config file contents:
 
<? The XML version="1.0" encoding="utf-8"?>






Because the IIS not familiar with, so in IIS configuration WebService only do the simple steps, building the application pool - & gt; Build a web site - & gt; To build an application - & gt; Set the directory browsing - & gt; Setup process mapping, ISAPI - DLL to provide WebService DLL,
  • Related