. NET 2.0 web services bug?

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.