Hi,
I will be extremely grateful for any hint what I am doing wrong consuming web service, which I am describing below.
I am calling external web service using SOAP protocol, which was delivered with the *.wsdl file. There is authentication through HTTPS and I received X.509 public key certificate from a provider. I thought that everything I should do I did right and I tried to use it from Microsoft Dynamics AX2012 R3, but after all, I cannot connect to the web service as I get the error message:
<em>System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at example.com/.../Service that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond ***.</em>
So I created a separate class in Microsoft Visual Studio and tried to call this web service from Microsoft Visual Studio level, but I got the same error.
What I already did:
1. Provider asked me to change web service endpoint, so before adding a service reference, I changed it in the *.wsdl file.
2. I added service reference in Microsoft Visual Studio.
3. After that, my app.config was generated like below, endpoint looks ok.
4. I created a new class to load provided certificate and test out the connection, code below.
After debugging this code, certificate seems to be found and loaded, but after invoking service.putData() method, I am receiving timeout and error that there is no endpoint.
==> Service / app.config
<?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <bindings> <customBinding> <binding name="DistributorServiceBinding"> <textMessageEncoding messageVersion="Soap12" /> <httpsTransport /> </binding> </customBinding> </bindings> <client> <endpoint address="example.com/.../DistributorsService" binding="customBinding" bindingConfiguration="DistributorServiceBinding" contract="Service.DistributorServiceType" name="DistributorServicePort" /> </client> </system.serviceModel>
==> Service / ConsoleApp.cs
class ConsoleApp { static void Main(string[] args) { try { DistributorServiceTypeClient client = new DistributorServiceTypeClient(); // Loading and assigning certificated stored for my user. It seems to be found and set as I am debugging. client.ClientCredentials.ClientCertificate.Certificate = ConsoleApp.setCertificate(); client.Open(); DataRequest request = new DataRequest(); // Some code to set DataRequest. DataResponse response = new DataResponse(); // Sending data. response = client.PutData(request); // ERROR is caught that no endpoint is listening. client.Close(); Console.WriteLine("Result : {0}", response.get_Result()); Console.WriteLine("Message : {0}", response.get_Message()); Console.ReadKey(); } catch (Exception e) { ... } } }
*This post is locked for comments
I have the same question (0)Hello,
Just in case anybody is working on this, I managed to set a batch job, which is calling this web service over https using client certificate and described it here: [link deleted].
I hope it will help somebody!