1

有人可以帮我吗?我正在尝试以编程方式在项目服务器(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);
4

1 回答 1

0

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

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

查看此线程以获取更多信息。

于 2011-01-19T14:15:59.273 回答