Hi,
Can someone please kindly help young lady with low skills in setting WebServices with a kind detailed advice, please.
I am getting an error:
System.ServiceModel.Security.MessageSecurityException: 'The HTTP request was forbidden with client authentication scheme 'Negotiate'.'
WebException: The remote server returned an error: (403) Forbidden.
The fun stuff is if in Internet browser I use link in as "HTTPS" I can open the service, however not as "HTTP".
I have tried to change as HTTPS in the config file, but it does not work and and asking for some sort of URI to be set-up.
I have tried to change security from "Windows" to "Ntlm", and even set it to "None" in the C# programme code, but I had no any luck. Scheme just changes to "Anonymous" and access is still forbiden.
The config file is like that:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="NDataAccessSoap" />
</basicHttpBinding>
<customBinding>
<binding name="NDataAccessSoap12">
<textMessageEncoding messageVersion="Soap12" />
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://XXXXX/YYYYY/VVVVV.asmx"
binding="basicHttpBinding" bindingConfiguration="NDataAccessSoap"
contract="devCARE.NDataAccessSoap" name="NDataAccessSoap" />
<endpoint address="http://XXXXX/YYYYY/VVVVV.asmx"
binding="customBinding" bindingConfiguration="NDataAccessSoap12"
contract="devCARE.NDataAccessSoap" name="NDataAccessSoap12" />
</client>
</system.serviceModel>
<connectionStrings>
<add name="CARELive_ConnectionString" connectionString="Data Source=SERVER1;Initial Catalog=DATABASE1;Integrated Security=True;" />
<add name="CARE_UserDefined_ConnectionString" connectionString="Data Source= SERVER2;Initial Catalog=DATABASE2;Integrated Security=True;" />
<add name="CAREUserDefined_DEV_ConnectionString" connectionString="Data Source=SERVER3;Initial Catalog=DATABASE3;Integrated Security=True;" />
</connectionStrings>
<appSettings>
<add key="DeleteWebService_RunFile_Path" value="\\ZZZ\Run.txt"/>
<add key="DeleteWebService_URL" value="http://XXXXX/YYYYY/VVVVV.asmx"/>
<add key="GetContactsForDeletion_SPName" value="dbo.sp_1"/>
<add key="WritToLog_SPName" value="dbo.sp_2"/>
<add key="CheckRecordAfterWSDelete_SPName" value="dbo.sp_3"/>
<add key="Public_Delete_SPName" value="dbo.sp_4"/>
<add key="ShowOutput" value ="Y"/>
<add key="KeepOutputWindowOpen" value ="N"/>
</appSettings>
</configuration>
C# Console Application programme code is like that:
static void Main(string[] args)
{
BasicHttpBinding binding = new BasicHttpBinding();
binding.MaxBufferPoolSize = 65535;
binding.MaxBufferSize = 65535;
binding.MaxReceivedMessageSize = 65535;
binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
var endpoint = new EndpointAddress(ConfigurationManager.AppSettings["DeleteWebService_URL"].ToString());
//string showOutput = ConfigurationManager.AppSettings["ShowOutput"].ToString();
string sKeepWindowOpen = ConfigurationManager.AppSettings["KeepOutputWindowOpen"].ToString();
devCARE.NDataAccessSoapClient service = new devCARE.NDataAccessSoapClient(binding, endpoint);
var database = service.GetAvailableDatabases(string.Empty).ToString();
if (sKeepWindowOpen.ToUpper() == "Y")
Console.ReadLine();
}
static private void TESTPublicDelete(string pPublic_Delete)
{
SqlConnection sqlConn = null;
SqlCommand sqlComm = null;
string sCareConnection = ConfigurationManager.ConnectionStrings["CARE_UserDefined_ConnectionString"].ConnectionString;
string sRecordsForDeletionSP = ConfigurationManager.AppSettings["TestSP"].ToString();
try
{
sqlConn = new SqlConnection(sCareConnection);
sqlComm = new System.Data.SqlClient.SqlCommand(sRecordsForDeletionSP, sqlConn);
sqlComm.CommandType = CommandType.StoredProcedure;
sqlConn.Open();
sqlComm.ExecuteNonQuery();
}
catch (Exception ex)
{
string err = ex.Message;
}
finally
{
sqlComm.Dispose();
if (sqlConn.State == ConnectionState.Open)
sqlConn.Close();
sqlConn.Dispose();
}
}
Thank you very much,
Jane.