A number of people have recently asked me how to use Connect Web Services for SOAP from an Add-In. I have published a number of sample videos for using various features of the Connect Web Services API, in these videos I create a console application. The nice thing about a console application is it can read in a configuration file, such as the app.config file that is created when you generate client side bindings from the WSDL. The challenge for Add-In developers is the app.config approach doesn’t work, so how do we get around this? The answer is actually pretty simple, we just need to build the functionality of the app.config file in code. I have provided sample code which does this below. Add-In developers can simply copy and paste this code into their Add-In, remove the configuration file, update the endpoint and credentials and begin using Connect Web Services from their Add-In. Happy coding!
Please note the sample code below falls under ourĀ Sample Code Legal Disclaimer.
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
EndpointAddress endPointAddr = new EndpointAddress("https://comland-10-8-7-16-v2.dx.lan/cgi-bin/comland_10_8_7_16_v2.cfg/services/soap");
_client = new RightNowSyncPortClient(binding, endPointAddr);
_client.ClientCredentials.UserName.UserName = "Connect";
_client.ClientCredentials.UserName.Password = "Connect";
BindingElementCollection elements = _client.Endpoint.Binding.CreateBindingElements();_client.Endpoint.Binding = new CustomBinding(elements);
elements.Find().IncludeTimestamp = false;

Leave a Reply