Sending XML file to a remote web service in different domain

Sayan81Sayan81 Member Posts: 10
edited 2012-09-07 in NAV Three Tier
Hi ,

I have two seperate domain running on two different LAN ( different location ) and NAV with 3 tier architecture has been installed in both places ( 3 tier on 3 machines ). Both the servers have got static IP. I am creating an XML file in one of the server and I need to transfer that XML file to other server. Is there any way to achieve this ? ( Apart from doing FTP ? )

Thanks in advance for your help.

Regards,
Sayan

Answers

  • Alex_ChowAlex_Chow Member Posts: 5,063
    Sayan81 wrote:
    Hi ,

    I have two seperate domain running on two different LAN ( different location ) and NAV with 3 tier architecture has been installed in both places ( 3 tier on 3 machines ). Both the servers have got static IP. I am creating an XML file in one of the server and I need to transfer that XML file to other server. Is there any way to achieve this ? ( Apart from doing FTP ? )

    Thanks in advance for your help.

    Regards,
    Sayan


    Webservice.
  • Sayan81Sayan81 Member Posts: 10
    Hi Alex,

    Thanks for your reply. Could you please explain a bit .

    My idea is that - In one NAV server, user will be entering data in some specific tables and a batch job will b erun that will export all teh records in an XML file and then it will call a NAV web service ( a codeunit published ) in the remote computer that will read through this XML file and will populate records in the other database ( So kind of data replication ). This is working fine when both the servers are in same network i.e. domain.
    But when servers are different domain , then obviously the second web service cannot read through this xml file as the file has been stored in Server A and the web service account does not have any read permission to that folder path ( there is no VPN connection , so basically two are different domains, but the two servers have static IP ). So now I am planning to tranfer the XML file to the second server before the web service starts reading it.

    Is there any way to pass this XML file to that web service ? Currently I am using fairly simple code like following to call the remote web servivce -


    XMLHTTP.open('POST','http://' + SubsidiaryCompany."Company NST IP" + ':' +
    SubsidiaryCompany."Company NAV BS Port"+'/'+SubsidiaryCompany."Company NAV BS Name" +
    '/WS/' + SubsidiaryCompany."Company Name" + '/Codeunit/' + WSName,0,SubsidiaryCompany."User ID",
    SubsidiaryCompany.Password);
    XMLHTTP.setRequestHeader('Content-Type','Text/xml; charset=utf-8');
    XMLHTTP.setRequestHeader('SOAPAction','StartReadingFiles');
    XMLHTTP.setTimeouts(ConnectTimeOut,ConnectTimeOut,ConnectTimeOut,ReceiveTimeout);
    XMLHTTP.send(XMLText);

    where XMLText is a simple text file that contains the web servcice name , function name in a SAOP format.
  • Alex_ChowAlex_Chow Member Posts: 5,063
    Yes, that will work. Although with NAV2009, you don't need that much coding anymore.
  • Sayan81Sayan81 Member Posts: 10
    But how can I send an entire xml file within than request xmmlhttp.send () ?

    I tried to change XmmlText to BigText but that gives me runtime error as not a valid type for C/AL.

    I am wondering if I change it to XML Dom DOc AUtomation type , will it accept? I have to try this :-k
  • SaalekSaalek Member Posts: 181
    Hi

    You can do 2 thing

    1- Write XML structure directly on the function
    XMLHttp.send(' <xml .......' +
    '<tag1> sdsds </tag1>');

    2- use a XML Dom Document v6 automation.

    Bye
  • Sayan81Sayan81 Member Posts: 10
    Okk, finally I got it after lot of head banging \:D/

    Thanks Saalek for the suggestion but option no. 1 will not work as I am sending large amount of data so I cannot encapsulate that in the text string as that will exceed 1024 charecter.

    SO I figured out I have to pass it as XML Dom Doc automation. So in the receiveing function in the codeunit ( that has been exposed as web service ) I defined the parameter as XML Dom Doc also. All well but when I ran the process , the web service returned me the error that NAVAutomation is not a valid datatype.

    So I changed the parameter to big text. Now everything went well excep the fact the tables in receiving end did not populate with data. After hours of investigation , I found that for some pecular reason when big text receives the XML file through web service , it just removes all XML tags and takes only the data. For eg <ID>1001</ID> will become only 1001.

    So at the end, just before sending the XML file , I marked the data part within CDATA format so that web service treats that as a text string only.

    And it worked !!!!!!!!!!!!! 8)
Sign In or Register to comment.