Oralce call Delphi Write DLL to access C # WebService problems

Source: Internet
Author: User
web| Access | Problem I want to access the WebService of C # written by an external DLL (written by Delphi) from Oracle's stored procedures, "CoInitialize not yet called" has occurred
I do not know what is going on, I hope you are pointing twos.
1, I wrote a function in Oracle Addnumber as follows:
The CREATE OR REPLACE FUNCTION "my". ADD "(A in Binary_integer,b
In Binary_integer) return Binary_integer as
EXTERNAL LIBRARY My_lib
NAME "Addnumber"
LANGUAGE C;
2, wrote a process addtest as follows:
CREATE OR REPLACE PROCEDURE "my". Addtest "(A In
Binary_integer,b in Binary_integer)
As
RetVal Binary_integer;
Begin
Retval:=add (A,B);
End
3, created the My_lib package:
CREATE OR REPLACE LIBRARY my_lib as ' C:\oracle\ora92\bin\MyWebservice.dll ';
4, in Delphi created a MyWebservice.dll, and copy it to the $oracle_home$\bin directory, which has a method:
Interface
function Addnumber (A:integer;b:integer): integer;cdecl;
....
Implementation
Procedure Dogetwebserviceerr (errmsg:string);
Var
Logfile:textfile;
I:integer;
Begin
AssignFile (LogFile, ' d:\test.txt ');
Try
Rewrite (LogFile);
Write (LOGFILE,ERRMSG);
Finally
CloseFile (LogFile);
End
End
function Addnumber (a:integer;b:integer): integer;
Begin
Try
Result: = Getmywebservicesoap (). Addnumber (A,B);
Except
On E:exception do Dogetwebserviceerr (E. e.message);
Else
Result: =-1;
End
End
.....
Where: Getmywebservicesoap () is one of the methods I used to import the generated Mywebservice.pas with the WSDL importer.
I have exported this method in the project file for this DLL:
Exports
Addnumber;
5, with C # in localhost created a web Service called MyWebService, which has a Web method called Addnumber, which is defined as follows:
[WebMethod]
public int addnumber (int a,int b)
{
return a+b;
}
6. I wrote a Windows Form client in C #, testing the Web method by calling the DLL written above with Delphi, and testing successfully
[DllImport (Dllpath,entrypoint = "MyWebservice.dll", CharSet = CharSet.Auto, callingconvention = Callingconvention.stdcall)]
private extern static int addnumber (int a,int b);
......
Test button
private void Buttontestwebservice_click (object sender, System.EventArgs e)
{
Consle.write (Addnumber (1,2));
}
7, in the Sql*plus test failed, open Test.txt file content is "not called CoInitialize", the test code is as follows
EXECUTE addtest (1,1);
If you change the Addnumber in Delphi to
function Addnumber (a:integer;b:integer): integer;
Begin
Try
Result: =a+b;//does not call WebService, direct calculation
Except
On E:exception do Dogetwebserviceerr (E. e.message);
Else
Result: =-1;
End
End
Execution is successful.
Oracle's Listener.ora and Tnsnames.ora are configured as follows
# LISTENER. ORA Network Configuration File:c:\oracle\ora92\network\admin\listener.ora
# Generated by Oracle configuration tools.
My_extproc_listener =

(Address_list =
(Address= (PROTOCOL=IPC)
(KEY = Extproc)
)
)
Sid_list_my_extproc_listener =
(Sid_list =
(Sid_desc =
(Sid_name = Extproc)
(Oracle_home = C:\oracle\ora92)
(program= C:\oracle\ora92\bin\extproc)
(envs= "Extproc_dlls=any")
)
)
# TNSNAMES. ORA Network Configuration File:c:\oracle\ora92\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.

Extproc_connection_data. World =
(DESCRIPTION =
(address = (PROTOCOL = IPC) (KEY = Extproc))
(Connect_data =
(SID = Extproc)
)
)




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.