We’ve developed some resources to help you work effectively from home during COVID-19 Click to learn more

SO database access in custom app

Hello,

I'm creating a custom app for CRM Online.

I've downloaded the example called IntegrationServerExample from this page.

The example is great, but one moment is not completely clear for me there. When a callback function calls

SoSession.Authenticate(new SoCredentials() { Ticket = context.Ticket })

 it fails with an exception

SuperOffice.Exceptions.SoDbAccessException: Unable to open ADO.NET database connection. Connection string: Server=;Database=;User ID=;

I see that there is a configuration for the database in Web.config and seems that it should contain credentials for CRM Online database. But it's not full:

 

 

 

I'm wondering where I can get those credentials.

Could anyone help me please?

 

Best regards,

Alona

RE: SO database access in custom app

HI Alona,

The IntegrationServer example is for creating an Online Quote Connector. The way authentication in this example works is that the remotebaseurl is set automatically from the online tenants context using the ContextInitializer and ContextResolver (in the Auth folder). In that case, the Services mode should be Remote. 

The examples web.config contains a services section where the Default Mode should be set to remote.

I downloaded it and see that it is set to local, which is wrong.

<Services>
      <!-- Mode can be Local, Remote, Switch -->
      <add key="DefaultMode" value="Remote"/>
</Services>

You could also programmatically do that in the ContextInitializer:

/// <summary>
/// Plugin responsible for setting tenant specific information, like service url
/// </summary>
[ContextInitializerPlugin("OnlineTenantContextInitializer")]
public class ContextInitializer : IContextInitializerPlugin
{
    public void InitializeContext(string contextIdentifier)
    {
        var context = SuperOfficeAuthHelper.Context;
        if (context != null && String.Equals(contextIdentifier, context.ContextIdentifier, StringComparison.InvariantCultureIgnoreCase))
        {
            // set the default mode to remote
            SuperOffice.Configuration.ConfigFile.Services.DefaultMode = SuperOffice.CRM.Services.ServiceMode.Remote;
            // Set the tenants url.
            SuperOffice.Configuration.ConfigFile.WebServices.RemoteBaseURL = context.NetServerUrl;
        }
        
    }
}

Hope this helps

Av: Tony Yates 26. apr 2018

RE: SO database access in custom app

Hi Tony,

 

That helped, thanks!

 

But a new exception appered:

SuperOffice.Exceptions.SoSessionException: Authentication failed! ---> SuperOffice.Exceptions.SoException: Unable to determine version of web services!

 

Do you have a clue on this?

 

Best regards.

Alona

Av: Alona Kysil 26. apr 2018

RE: SO database access in custom app

Hi!

You will have to step through it with a debugger and inspect what the NetServer URL is in the ContextInitializer. Is it getting set to an expected value? What is the value? 

It should be something like https://sod.superoffice.com/Cust54321/Remote/Services##. What's the number?

If you continue to have issues with it, please see the red line at the top of the accompanying document, SuperOffice Integration Service.docx, and send a request to that email address.

Best regards.

Av: Tony Yates 27. apr 2018

RE: SO database access in custom app

Hi Alona,

is this the new app I set up for you? If so, it only has WebApi (Rest) end-points enabled.

Av: Margrethe Romnes 27. apr 2018

RE: SO database access in custom app

Well, that would certainly explain the observed error message. :-)

That Quote Connectors example expects NetServer SOAP web services.

Av: Tony Yates 27. apr 2018

RE: SO database access in custom app

Hi Margrethe and Tony,

 

Thank you for the replies.

Yes, that's the app Margrethe created recently. In the context I have https://sod.superoffice.com/CustXXXXX/api/ as the NetServerUrl. So you are right :) Thanks for clarifuing the issue.

 

I'm wondering if there is an example which works with the REST API?

 

Best regards,

Alona

 

 

Av: Alona Kysil 27. apr 2018

RE: SO database access in custom app

Hi Alona,

Let's examine what the online quote connector example is all about. It's primary purpose is to be a data source for a quote connections configured in SuperOffice Admin. At its core, in the Services directory, is the QuoteConnector.svc endpoint, a WCF SOAP web service, that receives requests from SuperOffice CRM Online.

The contract that SuperOffice CRM Online expects to be able to communicate is that from which the QuoteConnector service inherits. This is a well-defined contract that must facilitate all of the API calls expected of a quote connector.

With that in mind, as long as SuperOffice CRM Online is able to connect to and exchange data as per that contract, then you are free to integrate with it as you see fit.

Now, we hoped to be able to pass all of the data you might need in order to process a quote routine, but sometimes more information is needed and a request back to the tenant is required. If you want to get additional information as a REST request, there is nothing stopping you from doing that.

When the service calls the Execute method, the service has everything (authentication-wise) to proceed with followup requests any way you like.

What specifically are you trying to do? If it is to build a quote connector, great! If it's something else, well that's a completely different discussion.

Best regards.

Av: Tony Yates 27. apr 2018

RE: SO database access in custom app

Hi Tony,

 

My ain was just to build a PoC application that communicates with the SO REST API. Now I found the documentation and seems that it works fine for me.

 

Thank you for help!

 

Best regards,

Alona

Av: Alona Kysil 30. apr 2018