调用 PSI Web 服务时出错:HTTP 请求未经客户端身份验证方案“匿名”授权

发布于 2024-10-08 18:06:35 字数 1498 浏览 5 评论 0原文

有人可以帮我吗?我正在尝试以编程方式在项目服务器(PSI webservice)中创建一个项目,但由于以下错误而未能这样做。有谁知道可能是什么问题?当我尝试在 VS2008 中更新 Web 服务时,我也收到此错误。

这是错误,当我调用 QueueCreateProject 时会发生这种情况(请参阅下面的代码):

System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM'. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.
   at System.Net.HttpWebRequest.GetResponse()
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   --- End of inner exception stack trace ---

这是代码:

       objProject = new pstest.ProjectWS.ProjectSoapClient();

           dsProjectDataSet = new pstest.ProjectWS.ProjectDataSet();
            ProjectWS.ProjectDataSet.ProjectRow projectRow = dsProjectDataSet.Project.NewProjectRow();
            Guid _projectGUID = Guid.NewGuid(); // new GUID for each project
            projectRow.PROJ_UID = _projectGUID;
            projectRow.PROJ_NAME = "My new Project";
            projectRow.PROJ_INFO_START_DATE = System.DateTime.Now;
            projectRow.PROJ_TYPE = 0; //0 is for project and 1 is for template
            dsProjectDataSet.Project.AddProjectRow(projectRow);

            //create a project using project.asmx

            objProject.QueueCreateProject(Guid.NewGuid(), dsProjectDataSet,false);

Could someone please help me? I am trying to create a project in project server programatically (PSI webservice) but am failing to do so because of the error below. Does anyone know what might be the issue? I am also getting this error when attempting to update the web service in VS2008.

Here is the error and it happens when I call QueueCreateProject (see code below):

System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM'. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.
   at System.Net.HttpWebRequest.GetResponse()
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   --- End of inner exception stack trace ---

Here is the code:

       objProject = new pstest.ProjectWS.ProjectSoapClient();

           dsProjectDataSet = new pstest.ProjectWS.ProjectDataSet();
            ProjectWS.ProjectDataSet.ProjectRow projectRow = dsProjectDataSet.Project.NewProjectRow();
            Guid _projectGUID = Guid.NewGuid(); // new GUID for each project
            projectRow.PROJ_UID = _projectGUID;
            projectRow.PROJ_NAME = "My new Project";
            projectRow.PROJ_INFO_START_DATE = System.DateTime.Now;
            projectRow.PROJ_TYPE = 0; //0 is for project and 1 is for template
            dsProjectDataSet.Project.AddProjectRow(projectRow);

            //create a project using project.asmx

            objProject.QueueCreateProject(Guid.NewGuid(), dsProjectDataSet,false);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小巷里的女流氓 2024-10-15 18:06:35

您的 app.config 很可能配置错误。根据您的安全配置,您可能需要更改其中的一部分:

<security mode="TransportCredentialOnly">
  <transport clientCredentialType="Ntlm"/>
</security>

看看 此帖子了解更多信息。

Most likely your app.config is misconfigured. Depending on your security configuration, you probably need to change part of it:

<security mode="TransportCredentialOnly">
  <transport clientCredentialType="Ntlm"/>
</security>

Take a look at this thread for more information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文