Oralce called Delphi write DLL to visit the issue of C # WebService

  I think from Oracle stored procedure through an external dll (Delphi preparation) to visit the WebService write C #, a "not yet call CoInitialize" 
  Do not know how the case, hope that the guidance on January 2. 
  1, in Oracle, I wrote a function AddNumber as follows: 
  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, a process AddTest wrote 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 MY_LIB package: 
  CREATE OR REPLACE LIBRARY MY_LIB AS 'C: \ oracle \ ora92 \ bin \ MyWebservice.dll'; 
  4, Delphi, in the creation of a MyWebservice.dll and its copy to $ ORACLE_HOME $ \ BIN directory, which is one of the ways: 
  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 (EEMessage); 
  Else 
  Result: = 1; 
  End; 
  End; 
…..
  Of which: GetMyWebServiceSoap () Yes I use the WSDL Importer into MyWebService.pas generated in a way. 
  I Dll in the project document, the method is derived: 
  Exports 
AddNumber;
  5, using C # Localhost created a MyWebService called the Web Service, including a method known as AddNumber the WEB, which is defined as follows: 
[WebMethod]
  Public int AddNumber (int a, int b) 
  ( 
  Return a + b; 
  ) 
  6, I used to write c # a Windows Form client, by calling the above written by Delphi dll, testing the Web, tested 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 SQL * Plus, the test failed to open Test.txt contents of the documents "has yet to call CoInitialize", testing the code below 
  EXECUTE Addtest (1,1); 
  If Delphi will be revised to the AddNumber 
  Function AddNumber (a: integer; b: integer): Integer; 
  Begin 
  Try 
  Result: = a + b; / / call WebService, direct calculation 
  Except 
  On E: Exception do DoGetWebServiceErr (EEMessage); 
  Else 
  Result: = 1; 
  End; 
  End; 
  Implement successfully. 
  Oracle's Listener.ora tnsnames.ora and configuration are 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 = "= ANY EXTPROC_DLLS") 
)
)
  # 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) 
)
)

Bookmark it: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Google
  • DotNetKicks
  • DZone
  • Furl
  • Netvouz

Tags:

Releated Articles


0 Comments to “Oralce called Delphi write DLL to visit the issue of C # WebService”

No Comments. Send your comment.

Leave a Reply

You must be logged in to post a comment.