Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SPContext.Current在sharepoint网站下的web服务中为空_Sharepoint_Web Services - Fatal编程技术网

SPContext.Current在sharepoint网站下的web服务中为空

SPContext.Current在sharepoint网站下的web服务中为空,sharepoint,web-services,Sharepoint,Web Services,我正在SharePoint网站中公开一个web服务,例如 在web服务方法中,SPContext.Current似乎为空 (有趣的是,我正在看的是的第5章中的一个示例,它们在web服务中使用SPContext.Current) 你知道我错过了什么吗?提前感谢。您的子目录是否可能被设置为web应用程序,因此在不同的上下文中运行?我唯一看到SPContext.Current=null的时候是在不存在的虚拟位置(即仅正确一半的URL)调用web服务的时候 在问题说明中,您提到了“\u vti\u bi

我正在SharePoint网站中公开一个web服务,例如

在web服务方法中,
SPContext.Current
似乎为空

(有趣的是,我正在看的是的第5章中的一个示例,它们在web服务中使用
SPContext.Current


你知道我错过了什么吗?提前感谢。

您的子目录是否可能被设置为web应用程序,因此在不同的上下文中运行?

我唯一看到SPContext.Current=null的时候是在不存在的虚拟位置(即仅正确一半的URL)调用web服务的时候

在问题说明中,您提到了“\u vti\u bin/subdir”。我还没有在SharePoint中托管的Web服务中看到此子目录构造(免责声明:我的知识仅限于SharePoint中自定义Web服务的2或3个工作实现)

通常,你会

  • 将asmx直接放入12蜂箱的ISAPI文件夹中。这将映射到vti-bin。
  • 将程序集(如果有的话)放入GAC(或网站垃圾箱,但我建议使用GAC,直到基本功能启动并运行为止)
  • 如果你真的需要,做一些发现的事情,但是对于测试来说,这应该不是必要的

它可能一点也不相关,但我还是会先尝试从vti文件箱开始工作,然后尝试处理子文件夹。SharePoint的url虚拟化可能很痛苦

您如何调用Web服务?这是来自javascript/jquery的ajax调用吗?如果是,您是否在webservice类上添加了ScriptService属性

[System.Web.Scripts.Services.ScriptService]
public class SimpleWebService : System.Web.Services.WebService
{
    ...
    ...
}

http://server是一个有效的web应用程序。问题是“subdir”是否也是一个应用程序,它将取代父目录的应用程序,并提供一个SP未运行的不同上下文。您可以通过检查调试器中“System.Web.Hosting.HostingEnvironment”的属性来确定这一点。将尝试。。。正如您所提到的,所有内容都托管在ISAPI目录下,代码保存在GAC’ed dll中,等等。Web服务实际上可以工作。谢谢。注意:如果在服务中调用代码,比如OWSTIMER(timer作业),您也会得到SPContext.Current=null。我发现了类似的情况。我用错误的url调用了svc(指向一个已删除的spsite),SPContext为空。是的,是的,我添加了ScriptService attrib,但我不确定在任何情况下如何关联。谢谢。你能提供更多的信息和代码示例吗?SPContext.Current中的哪个特定对象为空?如何获取web服务的凭据?您正在使用什么身份验证?+承载IIS站点的是Windows authN。(这与SPContext.Current为null有什么关系?)