Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > HTTP Service and External Data Source (Read)

Forum

Search UsersRules
HTTP Service and External Data Source (Read)
#1
Active user
Points:: 0
Joined:: Feb 26, 2015

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

Profile
#2
Active user
Points:: 0
Joined:: Apr 18, 2012

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?

Profile
#3
Active user
Points:: 0
Joined:: Feb 26, 2015

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

Profile
#4
Active user
Points:: 0
Joined:: Apr 18, 2012

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

Profile
#5
Active user
Points:: 0
Joined:: Feb 26, 2015

Yes.

Profile
#6
Active user
Points:: 0
Joined:: Apr 18, 2012

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

Profile
#7
Active user
Points:: 0
Joined:: Feb 26, 2015

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.

Profile
#8
Active user
Points:: 0
Joined:: Apr 18, 2012

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();

Profile
#9
Active user
Points:: 0
Joined:: Feb 26, 2015

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.

Profile
#10
Active user
Points:: 0
Joined:: Feb 26, 2015

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

Profile
#11
Active user
Points:: 0
Joined:: Feb 26, 2015

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

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



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.