I am developing a custom SharePoint Application page. This page has a button which calls a web service. I managed to get it to run just fine, and was also able to deploy it successfully.
However, in PROD environment, calling the web service on button click is displaying the following exception message:
Could not find endpoint element with name 'NetTcpBinding_LSCCertificateService' and contract 'AXWebService.LSCCertificateService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.
I have modified the C:\inetpub\wwwroot\wss\VirtualDirectories\80\web.config
file by adding the following lines to the very end of the document, just before the last closing </configuration>
tag:
...
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_LSCCertificateService" />
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://OSMDEVAOS01:8201/DynamicsAx/Services/LSCTCTSGroup"
binding="netTcpBinding" bindingConfiguration="NetTcpBinding_LSCCertificateService" contract="AXWebServices.LSCCertificateService" name="NetTcpBinding_LSCCertificateService">
<identity>
<userPrincipalName value="[email protected]" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
The button's event handler method calling the web service is:
{
...
Item document = new Item();
document.ActionType = LSCActionType.Insert;
document.CertificateType = itemID;
document.PersonnelNumber = personID;
LSCCertificateServiceClient client =
new LSCCertificateServiceClient("NetTcpBinding_LSCCertificateService");
client.saveChanges(new CallContext(), document);
}
And another thing; I have developed a SharePoint Timer Job Definition which calls that exact same method from above. Its OWSTIMER.exe.config
file contains the same configuration mentioned above as does the web.config
. The job runs with no issues. This leads me to the conclusion that the configuration itself is correct. But why is the button event handler firing error and not being able to read the web.config
?