Call Function in Codeunit with Webservice

Florian48SFlorian48S Member Posts: 1
Hello I want to HTTP Post from one NAV DB to another with Webservice.
I created the webservice entry in the one and the function on the HTTP Client.
When I start this function I receive status code 500 Error.

My URI is like:
http://server:port/instance/WS/companyname/Codeunit/webservicename:codeunitfunctionname

When I try to do the same with the same URI except I delete :codeunitfunctionname I receive status code 200 OK.
But then it does nothing because I need to call the codeunit function.

What is wrong??

Here the Code from the HttpClient:
Uri := Uri.Uri('http://server:port/instance/WS/companyname/Codeunit/webservicename: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 is the Function I want to POST to:
ajnibo07njvs.png

Here is the error in the Event viewer on the Server I POST to:
0swti96qp0yw.png





Or is there a problem with the firewall or on the server?
The two NAV's are in the same Domain but different servers.

Answers

  • jordi79jordi79 Member Posts: 272
    Hi,
    Did you test the webservice calls with a 3rd party soap client first? such as POSTMAN or Chrome boomerang extension? This will eliminate any firewall related issues.
  • Dekker8Dekker8 Member Posts: 14
    Hi,
    As I see from error, it can be internal error on database that you tries to connect (means something going wrong in procedure that you calling saveXML as I see) maybe this procedure was not have
    External property because message said that saveXML procedure as not found.

Sign In or Register to comment.