Hello
We are using NAV 2017. We have two NAV DB's on two different Servers but same Domain. I want to send XMLPORT data to the other Navision with a webservice. I can't make a GET on the other DB. I need to make a POST or something.
NAV1 = Navision Company which sends date.
NAV2 = Navision Company which should receive the data
On NAV2 I created a Codeunit with Function saveXML(). This Codeunit I created an entry on the table "Web service" and published it.
On NAV1 I have a XMLPORT which I want to send to the function saveXML(). I want to do this with a webservice but I don't know how to call the function excatly. I can call the servicename from the Codeunit and receive ResponseMessage 200 OK. But nothing happens because I also need to call the FUNCTION not only the CODEUNIT.
I tried to add :codeunitfunctionname at the end of uri but then I receive status code 500 internal error and on the event viewer ServiceBrokerException "servicename:codeunitfunction" not found
Here is the Code from NAV1:
tempBlob.DELETEALL;tempBlob."Primary Key" := 1;tempBlob.INSERT;tempBlob.Blob.CREATEOUTSTREAM(OutStr,TEXTENCODING::UTF16);ICXML.SETTABLEVIEW(pICShip);ICXML.SETDESTINATION(OutStr);ICXML.FILENAME('test.XML');ICXML.EXPORT();tempBlob.MODIFY;
IF NOT tempBlob.Blob.HASVALUE() THEN EXIT;
tempBlob.CALCFIELDS(Blob);tempBlob.Blob.CREATEINSTREAM(InStr);InStr.READTEXT(txtResult);
WHILE NOT InStr.EOS() DO BEGIN InStr.READTEXT(Line); txtResult += Line;END;
Uri := Uri.Uri('servername:port/instance/WS/companyname/Codeunit/servicename:codeunitfunctionname');HttpHandler := HttpHandler.HttpClientHandler;NCredentials := NCredentials.NetworkCredential(username, password);HttpHandler.Credentials(NCredentials);HttpClient := HttpClient.HttpClient(HttpHandler);StringContent := StringContent.StringContent(txtResult,Encoding.UTF8,'application/xml');
ResponseMessage := HttpClient.PostAsync(Uri,StringContent).Result;
And here the function from NAV2:
saveXML(pXmlUpdateIn : Text)lFile.CREATE(filename);lFile.CREATEOUTSTREAM(Outstr);Outstr.WRITETEXT(pXmlUpdateIn);
Maybe there is another way to send this with webservice than with the code from NAV1 but I dont find any? Especially for sending the data to the FUNCTION in the codeunit.
Can somebody help me please?

Report
All responses (
Answers (