0

I have a web application in .net core from which I access a web service (soap). When I send a post, I receive the following message:

The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.

my code looks like:

BusinessCentral_PortClient client= new BusinessCentral_PortClient();

string username = "username ";
string password = "password";

client.ClientCredentials.UserName.UserName = username;
client.ClientCredentials.UserName.Password = password;

client.Send();

In the fiddler, It can be verified that the request has a wrong Authorization attribute because it does not contain the correct value.

POST http://MyHost_3030/WS/Codeunit/Accounting?wsdl HTTP/1.1
Host: MyHost_3030
Cache-Control: no-cache, max-age=0
SOAPAction: "urn:microsoft-dynamics-schemas/codeunit/Accounting:SendInvoice"
Accept-Encoding: gzip, deflate
Authorization: Basic Og==
Content-Type: text/xml; charset=utf-8
Content-Length: 1137

And consequently, the response reflects this error.

HTTP/1.1 500 Internal Server Error
Content-Length: 0
Server: Microsoft-HTTPAPI/2.0
NAV-Error: Username cannot be empty.
WWW-Authenticate: Basic realm=""
Date: Wed, 05 Apr 2023 15:33:36 GMT

Ive tried also with the http digest

//BusinessCentral_PortClient is a wsdl chanel autogenerated that inherit from
//System.ServiceModel.ClientBase<ConsoleApp2.ServiceReference1.IntegracionContabilidad_Port>

BusinessCentral_PortClient client= new BusinessCentral_PortClient();

string username = "username ";
string password = "password";

client.ClientCredentials.UserName.UserName = username;
client.ClientCredentials.UserName.Password = password;
client.ClientCredentials.HttpDigest.ClientCredential = new NetworkCredential(username, password);

client.Send();

ALso when I send the request using SOAP UI, everything go well

HTTP/1.1 200 OK Content-Length: 406 Content-Type: text/xml; charset=utf-8 Server: Microsoft-HTTPAPI/2.0 Date: Wed, 05 Apr 2023 15:21:31 GMT

Could you help please Thank you

0 Answers0