Hello,
We came across an issue when calling the Dynamics 365 API from a webservice (which is our intranet http site). It works fine if it runs as an exe locally, but it fails when it is called from a web service via a dll. Please note, the code is exactly the same. We suspect it is a call for https while we are making a http request. However, our https is open too. Do you have any suggestion on what we could do or do you have any idea why this happens?
And here is the error.
The remote server returned an error: (500) Internal Server Error.
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Server was unable to process request. ---> An error occurred while making the HTTP request to https://xxx.sandbox.operations.dynamics.com/soap/services/dmImgOurServiceGroup. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server. ---> The underlying connection was closed: An unexpected error occurred on a send. ---> Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> An existing connection was forcibly closed by the remote host</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>
And here is the source code:
using (new OperationContextScope(Client365.InnerChannel)) { string auth = "Bearer " authToken; HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty(); requestMessage.Headers["Authorization"] = auth; OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage; dtNow = DateTime.UtcNow; Client365.GetLog(c, qc, out Log365); }