what can cause the above error when connecting to an endpoint via a c# app? the app, and sql are both on my machine ( im just doing this for test purposes and to learn something new.)
i added this code on advice from a web site to the Reference.cs file:
{
HttpWebRequest webRequest = (HttpWebRequest) base.GetWebRequest(uri);
webRequest.KeepAlive = false;
webRequest.ProtocolVersion=HttpVersion.Version10;
return webRequest;
}
Now i get this error.
"The request failed with HTTP status 401: Unauthorized."
this is strange as i have granted the user who the application is running under control access to the endpoint, and even to the function behind the endpoint.
Here is the code behind the button for calling the web service:
private void button1_Click(object sender, EventArgs e)
{
try
{
v_fintag.my_Endpoint wsObject = new v_fintag.my_Endpoint();
wsObject.Credentials = System.Net.CredentialCache.DefaultCredentials;
System.Data.SqlTypes.SqlInt32 sqlint;
sqlint = 25;
System.Data.SqlTypes.SqlString sqlStr;
sqlStr = wsObject.GetFunctionData(sqlint);
}
catch (Exception ET)
{
label2.Text = ET.Message + " : " + ET.Data;
}
}
Also, here is the endpoint, in case its useful or provides information:
create endpoint my_Endpoint
state = started
as http(path='/sql',
authentication=(INTEGRATED),
PORTS=(CLEAR),
SITE='*')
For SOAP
(
webmethod 'GetSprocData'(name='adventureworksdw.dbo.testEndPointSproc'),
webmethod 'GetFunctionData'(name='adventureworksdw.dbo.endpointFunctionTest'),
wsdl=default,
schema=standard,
database ='adventureworksdw',
namespace = 'myNamespace'
)
grant execute on dbo.endpointfunctiontest to [user1]
use master
GRANT CONNECT ON ENDPOINT:: my_Endpoint TO [user1]
No comments:
Post a Comment