Today, we tested. NET 2.0's WebService and found a major problem. The parameter cannot be obtained. The parameter is always null. Of course, there is no problem with using. Net calls, and the Web Test page is also normal. Both Delphi7 and Java call results are the same. Is it a. NET 2.0 bug?
Test results show that all value type parameters are default values, and all reference types are null.
The WebService code is as follows:
[Webmethod]
Public String echostring (string ARGs)
{
Return ARGs;
}
[Webmethod]
Public String echoint (INT ARGs)
{
Return args. tostring ();
}
Code called by Delphi
Procedure tform1.button3click (Sender: tobject );
VaR
SS: servicesoap;
Hello: widestring;
Begin
Try
Httprio1.wsdllocation: = edtaddress. text;
Httprio1.service: = edit3.text;
Httprio1.port: = edit4.text;
SS: = (httprio1 as servicesoap );
Hello: = 'hello ';
Memo1.lines. Add (ss. echoint (234 ));
Except
On E: exception do
Showmessage (E. Message );
End;
End;
Certificate --------------------------------------------------------------------------------------------------------------------------------------------------
The Web services generated by vs2003 are continuously found. Delphi does not have any problems during calling. Even delphi2006 cannot call the. NET 2.0 web service normally.
Finally, after unremitting efforts, we finally found a way to add a line in the WebServices declarative unit generated by Delphi.
Invregistry. registerinvokeoptions (typeinfo (servicesoap), iodocument );
For example:
Unit Service;
Interface
Uses invokeregistry, soaphttpclient, types, xsbuiltins;
Type
Servicesoap = interface (iinvokable)
['{77573149-9c57-fa51-f11f-efd527c91bd9}']
Function helloworld (const ASDF: widestring): widestring; stdcall;
End;
Implementation
Type
Servicesoapimpl = Class (tinvokableclass, servicesoap)
Public
{Servicesoap}
Function helloworld (const ASDF: widestring): widestring; stdcall;
End;
Function servicesoapimpl. helloworld (const ASDF: widestring): widestring;
Begin
{Todo-implement method helloworld}
End;
Initialization
Invregistry. registerinterface (typeinfo (servicesoap), 'HTTP: // tempuri.org/', 'utf-8 ');
Invregistry. registerinvokableclass (servicesoapimpl );
Invregistry. registerdefaultsoapaction (typeinfo (servicesoap), 'HTTP: // tempuri.org/helloworld ');
Invregistry. registerinvokeoptions (typeinfo (servicesoap), iodocument); // this line
End.
Now the problem is fixed.