The 1C:Enterprise developers forum

#1
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Feb 26, 2015
Company: Uguz Limited sirketi

Hello to everyone.
I can read operation with the HTTP service.
I want to read from the external data source.
But I can not.
Error code :
{HTTPService.Test.Module(19)} : An error occurred in the process of content method call ( Execute )


What am I doing wrong?



Code
Function TestTest(Request)
   Response = New HTTPServiceResponse(200);   
   Result = "";
   
   Query = New Query;
   Query.Text = 
      "SELECT
      |   dbo_TBL_KULLANICI.KULLANICI,
      |   dbo_TBL_KULLANICI.KULLANICI AS KULLANICI1,
      |   dbo_TBL_KULLANICI.KULLANICI AS KULLANICI2,
      |   dbo_TBL_KULLANICI.KULLANICI AS KULLANICI3,
      |   dbo_TBL_KULLANICI.KULLANICI AS KULLANICI4,
      |   dbo_TBL_KULLANICI.KULLANICI AS KULLANICI5,
      |   dbo_TBL_KULLANICI.KULLANICI AS KULLANICI6
      |FROM
      |   ExternalDataSource.demo_mtsk.Table.dbo_TBL_KULLANICI AS dbo_TBL_KULLANICI";
   
   QueryResult = Query.Execute();
   
   SelectionDetailRecords = QueryResult.Select();
   
     JSONWriter = New JSONWriter;
      JSONWriterSettings = New JSONWriterSettings(, Chars.Tab);
      JSONWriter.SetString(JSONWriterSettings);
    
       dizi = New Array;
      While SelectionDetailRecords.Next() Do
         
         yapi = New Structure;
         yapi.Insert("Tarih",SelectionDetailRecords[0]);
        yapi.Insert("Unvan",SelectionDetailRecords[1]);
        yapi.Insert("GorusmeTipi",SelectionDetailRecords[2]);
        yapi.Insert("GorusmeNedeni",SelectionDetailRecords[3]);
        yapi.Insert("GorusmeDurumu",SelectionDetailRecords[4]);
        yapi.Insert("GorusmeDetayi",SelectionDetailRecords[5]);
        yapi.Insert("GorusmeSonucu",SelectionDetailRecords[6]);
        dizi.Add(yapi);
     EndDo;
     WriteJSON(JSONWriter, dizi);
      Result = JSONWriter.Close();
       
                 
    Response = New HTTPServiceResponse(?(True, 200, 404));
   Response.SetBodyFromString(Result, TextEncoding.System);  
         Return Response;
   
EndFunction

Edited: Erdogan Uguz - Jul 03, 2016 04:00 AM
 
#2
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Apr 18, 2012
Company:

Hi, Erdogan Uguz!

Firstly check connection to external database.
Open "Main menu" - "All functions" - "External data sources" and sel ect required table.
Do you receive errors? Can you see data fr om external database?

Edited: Alexei Khatin - Jul 03, 2016 04:15 AM
 
#3
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Feb 26, 2015
Company: Uguz Limited sirketi

There are databases in Designer screen.
Adding the error did not.
Pictures here.

Download 1.png (22.07 KB)
Download 2.png (16.57 KB)
 
#4
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Apr 18, 2012
Company:

I meant to open the table in the "enterprise" mode.

Download 1.png (7.98 KB)
Download 2.png (16.22 KB)
 
#5
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Feb 26, 2015
Company: Uguz Limited sirketi

Yes.

Download 3.png (47.28 KB)
 
#6
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Apr 18, 2012
Company:

Does your database (1C) work in client-server mode?

Edited: Alexei Khatin - Jul 03, 2016 05:18 AM
 
#7
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Feb 26, 2015
Company: Uguz Limited sirketi

I have 2 different servers.
The first server installed 1C. Microsoft SQL Server Standard License.
The second server in SQL Server Express Edition installed.
They tried my users can connect to the server 1C. (Web and Remote Access / 1C Ports Open)
Both servers also open access.

 
#8
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Apr 18, 2012
Company:

I suggest to set connection string before query

Code
ConnectionParameters = New ExternalDataSourceConnectionParameters;
ConnectionParameters.ConnectionString = "DRIVER={SQL Server};SERVER=your_server;DATABASE=your_database;";
ConnectionParameters.DBMS = "MSSQLServer";
ConnectionParameters.UserName = "sa";
ConnectionParameters.Password = "your_password";
ExternalDataSources.ExternalCatalogs.SetCommonConnectionParameters(ConnectionParameters);
ExternalDataSources.ExternalCatalogs.Connect();

 
#9
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Feb 26, 2015
Company: Uguz Limited sirketi

When trying to open a table;
- I have to write the connection string again.
- I have to write the database username and password.
- I have to give approval.
- After the table opens.

Download 4.png (52.76 KB)
Download 5.png (18.38 KB)
Download 6.png (51.07 KB)
Download 7.png (46.87 KB)
Download 8.png (43.06 KB)
 
#10
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Feb 26, 2015
Company: Uguz Limited sirketi

I will try and give you the information you send over.

Quote
I suggest to set connection string before query


ConnectionParameters = New ExternalDataSourceConnectionParameters;
ConnectionParameters.ConnectionString = "DRIVER={SQL Server};SERVER=your_server;DATABASE=your_database;";
ConnectionParameters.DBMS = "MSSQLServer";
ConnectionParameters.UserName = "sa";
ConnectionParameters.Password = "your_password";
ExternalDataSources.ExternalCatalogs.SetCommonConnectionParameters(ConnectionParameters);
ExternalDataSources.ExternalCatalogs.Connect();
Quote selected text in answer   Name

Edited: Erdogan Uguz - Jul 03, 2016 06:03 AM
 
#11
People who like this: 0 Yes / 0 No
Active user
Rating: 4
Joined: Feb 26, 2015
Company: Uguz Limited sirketi

Super answer.
Thank you so much.
Good work. ;)

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)