SQL 2005 has added a new feature called ENDPOINT. You can use it to created a webservice on SQL server and access it from Navision.
You can create a stored procedure in and call it from Navision through webservice. this is another way to do it instead of ADO. You can use this to load long strings which can be done by XMLPort using BigText.
Here is how to create a stored procedure and creating webservice for it.
create procedure dbo.GetEmployees
As
select [No_], [First Name], [Last Name]
FROM [Navision-5].[dbo].[KRONUS5$Employee]
go
Here is how create a webservice for this stored procedure.
CREATE ENDPOINT GetEmployees
STATE = STARTED
AS HTTP
(
PATH = '/Employee',
AUTHENTICATION = (INTEGRATED),
PORTS = (CLEAR),
CLEAR_PORT = 8000,
SITE = 'localhost'
)
FOR SOAP
(
WEBMETHOD 'EmployeeList'
(NAME='Navision-5.dbo.GetEmployees'),
BATCHES = DISABLED,
WSDL = DEFAULT,
DATABASE = 'Navision-5',
NAMESPACE = 'http://Navision-5/Employee'
)
go
In example above i’ve defined port 8000. To access the webservice through IE. Use the following address.
http://localhost:8000/Employee?wsdl
Here is Navision code on how to access this webservice.
IF ISCLEAR(XmlDoc) THEN
CREATE(XmlDoc);
IF ISCLEAR(XmlHttp) THEN
CREATE(XmlHttp);
TempFileName := 'c:\tempxmlfile';
MyFile.CREATE(TempFileName);
MyFile.TEXTMODE(TRUE);
MyFile.WRITEMODE(TRUE);
MyFile.WRITE('');
MyFile.WRITE('');
MyFile.WRITE('');
MyFile.WRITE('');
MyFile.WRITE('');
MyFile.WRITE('');
MyFile.CLOSE;
XmlDoc.async := FALSE;
XmlDoc.load(TempFileName);
XmlHttp.Open('POST','http://localhost:8000/Employee',0);
XmlHttp.SetRequestHeader('Content-type','text/xml');
XmlHttp.SetRequestHeader('SOAPAction','"http://Navision-5/EmployeeEmployeeList"');
XmlHttp.SetTimeouts(10000,10000,10000,10000);
XmlHttp.Send(XmlDoc);
IF XmlHttp.Status 200 THEN
message('Http Error ' + ' ' + FORMAT(XmlHttp.Status) + ': ' + XmlHttp.StatusText);
XmlDoc.async := FALSE;
XmlDoc.load(XmlHttp.ResponseBody);
XmlDoc.save('C:\response.xml');
HYPERLINK('C:\response.xml');
CLEAR(XmlDoc);
CLEAR(XmlHttp)
Here is the SQL Form Example to the Form.