Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: server was unable to process request. ---> Object reference not set to ...


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Mar 7, 2017 8:41 AM Last Post By: Carlos Saez
Carlos Saez

Posts: 20
Registered: 12/26/06
server was unable to process request. ---> Object reference not set to ...  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 11, 2017 4:26 PM
Subject: "server was unable to process request. ---> Object reference not set to an instance of an object", accessing a web service in DELPHI 7

I'm very new to web services, In fact this is the first one for which I've built a client to access to. I've imported WSDL and included the generated unit in a small sample program to test the access to the services.

The sample access to services that have not parameters, being the result of string type, get a result as expected. But when the service has parameters and a "complex" result, the execution of the web service gets: "server was unable to process request. ---> Object reference not set to an instance of an object" error message. Debugging the execution, I confirm that the parameters have value, although I know nothing about the result.

A sample of one of the services follows. I'd appreciate some guidance.

[WSDL]
...
<s:element name="MyService">
<s:complexType><s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Param1" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Param2" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Param3" type="s:string"/>
</s:sequence></s:complexType>
</s:element>
...
<s:element name="MyServiceResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="ActivaKeyEIResult" type="tns:MyServiceResult"/>
</s:sequence>
</s:complexType>
</s:element>
...
<s:complexType name="MyServiceResult">
<s:sequence><s:element minOccurs="1" maxOccurs="1" name="Error" type="s:boolean"/>
<s:element minOccurs="0" maxOccurs="1" name="Msg" type="s:string"/>
</s:sequence>
</s:complexType>
...

[Delphi WSDL Unit]
...
interface
type
...
MyServiceResult = class;
...
MyServiceResult = class(TRemotable)
private
FError: Boolean;
FMsg: WideString;
published
property Error: Boolean read FError write FError;
property Msg: WideString read FMsg write FMsg;
end;
...
MyWebServicesSoap = interface(IInvokable)
...
function MyService(const Param1: WideString; const Param2: WideString; const Param3: WideString): MyServiceResult; stdcall;
end;
...
initialization
RemClassRegistry.RegisterXSClass(MyServiceResult, 'http://mywebsite.com/', 'MyServiceResult');
...

[DELPHI client access]
...
type
TForm1 = class(TForm)
...
private
Cliente : MyWebServicesSoap;
end;
...
var
R_MyServiceResult : MyServiceResult;
...
procedure TForm1.FormCreate(Sender: TObject);
begin
Cliente:=GetMyWebServicesSoap;
R_MyServiceResult:=MyServiceResult.Create;
end;
...
procedure TForm1.Button1Click(Sender: TObject);
var
param1,param2,param3 : widestring;
begin
param1:='p1';
param2:='p2';
param3:='p3';
R_MyServiceResult:=Cliente.MyService(param1,param2,param3);
end;

Carlos Saez

Posts: 20
Registered: 12/26/06
Re: server was unable to process request. ---> Object reference not set to ...  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 7, 2017 8:41 AM   in response to: Carlos Saez in response to: Carlos Saez
For your information.

Finally, after reading some posts in various forums I've found a solution.

In my case, was a matter of including the sentence:

InvRegistry.RegisterInvokeOptions(TypeInfo(MyServiceName),ioDocument);

in initialization section of the WSDL generated unit, say after the generated sentence:

InvRegistry.RegisterInterface(TypeInfo(MyServiceName), 'http://WebServicesNameSpace', 'utf-8');
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02