Developer forum

Forum » Integration » NAV integration

NAV integration

Mikkel Toustrup Olsen
Reply

Hey guys,

I've probably stared myself blind on the documentation though..

I have a project in which I have a live integration setup for Importing Products, Users etc from an external NAVision.

The connection is open and I am able to fetch updates etc from NAV -> Dynamicweb. (1 way)

However, the customer want the ability to push changes from Dynamicweb -> NAV.

Changes from the User (email, phone, newsletter etc) which should end up in NAV - so basically a 2 way sync.

My question is then, what addin/logic to use for this?

I'm imagining something of the like:

1) When user changes his/her profile (OnUserSavedObserver) build request for NAV

2) Custom Dynamicweb Connector addin?:  https://doc.dynamicweb.com/documentation-8/integration/integration-framework/live-integration#sideNavTitle1-3

3) Push XML to webservice.

I've tried to build my XML request and next convert this to a string using a stringbuilder in order to parse the request as a string required by the endpoint..

However, when Requesting the following error occurs.

System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.  (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. 
   at System.Convert.FromBase64_ComputeResultLength(Char* inputPtr, Int32 inputLength)
   at System.Convert.FromBase64CharPtr(Char* inputPtr, Int32 inputLength)
   at System.Convert.FromBase64String(String s)
   at DynamicwebServiceClass.Crypto.DecryptStringAES(String cipherText, String sharedSecret) in c:\Projects\eCommerce\Integrations\DynamicwebConnectorService\DynamicwebServiceClass\Crypto.cs:line 99
   at DynamicwebServiceClass.DynamicwebService.DataRequest(String request) in c:\Projects\eCommerce\Integrations\DynamicwebConnectorService\DynamicwebServiceClass\DynamicwebService.cs:line 37
   at SyncInvokeDataRequest(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object ins...).

My wondering is, Isn't there something built in DW which could handle the above mentioned? - I tried to Inspect the call stack and regarding the Crypto / Decrypt logic it does not make sense for me to start encrypting/decrypting the request in order to push simple user changes to NAV ..

Anyone? :)

BR Mikkel


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply
This post has been marked as an answer

Hi Mikkel,

Looks like you are missing regular string while your DynamicwebConnector is configured with some "Secret" word, so you need to encode your request xml using that Secret.
In order to do this you can use the existing: Dynamicweb.DataIntegration.Integration.ERPIntegration.ErpServiceCaller class and call

public static string GetDataFromRequestString(string endpoint, string secret, string requestXML)

where "secret" needs to be the same as is used in the DynamicwebConnector config file "Secret" option.

You can call this method in your OnUserSavedObserver.
Regards, Dmitrij

Votes for this answer: 1
 
Mikkel Toustrup Olsen
Reply

Hi Dmitrij,

Thanks, I'll look into that! :)

BR Mikkel

 
Mikkel Toustrup Olsen
Reply

Update:

Sure did the trick Dmitrij, thanks for quick response :)

BR Mikkel

 

You must be logged in to post in the forum