如何从SharePoint 2010表单中调用/使用IIS中部署的WCF服务 [英] How to call/consume a wcf service deployed in IIS from sharepoint 2010 form
问题描述
我在IIS上部署了wcf服务.当我从浏览器http://SiteName:81/ServiceName.svc
访问该服务时,该服务正在运行
我还使用此服务在Sharepoint中使用BCS填充列表,效果很好.
我需要从Sharepoint表单调用此服务,我以为可以使用jQuery/Ajax完成此任务,但到目前为止我还没有成功.
我在表单中有以下代码(这是我正在处理的自定义列表的NewForm.aspx):
I have a wcf service deployed on IIS. The service is running when I access it from the browser http://SiteName:81/ServiceName.svc
I am also using this service to populate a list using BCS in Sharepoint which works fine.
I need to call this service from a Sharepoint form and I thought I could use jQuery/Ajax to accomplish this but so far I am not successful.
I have the following code inside the form(This is the NewForm.aspx for the custom list i am working on):
<script type="text/javascript">
$.ajax( {
type: "Get",
url: 'http://ServerName:81/mywebservice.svc',
success: function() {
alert("Service found);
},
error: function () {
alert("Service not found");
}
});
</script>
我不确定是要使用jQuery/Ajax还是要使用其他解决方案,还是应该放弃所有这些并创建具有所有现有功能的自定义表单.
如果可以调用该服务,则可以使用它的方法.
此外,我在Web服务的Visual Studio中运行了上述脚本,接受我必须用loocalhost替换ServerName,例如:"http://localhost:10006/mywebservice.svc". localhost:10006是VS Web服务.如果将其更改为ServerName:81,则无法找到服务.
任何对此的想法将不胜感激.
谢谢
Mustansir
I am unsure of whether jQuery/Ajax is the way to go or there is another solution or should I scrap all this and create a custom form with all the existing functionality.
If I can call the service then I can use it''s methods.
Also, I have the above script working within Visual Studio for the Web Service, accept that I have to replace the ServerName with loocalhost like this: ''http://localhost:10006/mywebservice.svc''. The localhost:10006 is the VS webservice. If I change it to ServerName:81 it fails to locate the service.
Any thoughts on this would be appreciated.
Thanks
Mustansir
推荐答案
.ajax({ 类型:" , 网址:' http://ServerName:81/mywebservice.svc', 成功:功能(){ alert(" 未找到服务 ); } }); </script>
.ajax( { type: "Get", url: 'http://ServerName:81/mywebservice.svc', success: function() { alert("Service found); }, error: function () { alert("Service not found"); } }); </script>
我不确定是要使用jQuery/Ajax还是要使用其他解决方案,还是应该放弃所有这些并创建具有所有现有功能的自定义表单.
如果可以调用该服务,则可以使用它的方法.
此外,我在Web服务的Visual Studio中运行了上述脚本,接受我必须用loocalhost替换ServerName,例如:"http://localhost:10006/mywebservice.svc". localhost:10006是VS Web服务.如果将其更改为ServerName:81,则无法找到服务.
任何对此的想法将不胜感激.
谢谢
Mustansir
I am unsure of whether jQuery/Ajax is the way to go or there is another solution or should I scrap all this and create a custom form with all the existing functionality.
If I can call the service then I can use it''s methods.
Also, I have the above script working within Visual Studio for the Web Service, accept that I have to replace the ServerName with loocalhost like this: ''http://localhost:10006/mywebservice.svc''. The localhost:10006 is the VS webservice. If I change it to ServerName:81 it fails to locate the service.
Any thoughts on this would be appreciated.
Thanks
Mustansir
这篇关于如何从SharePoint 2010表单中调用/使用IIS中部署的WCF服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!