MOSS2010中如何使用自定义WebService

1、 使用vs2012新建一个web services解决方案,因为DLL需要部署GAC中去,因此需要强签名。如下图:

2、 编写业务逻辑代码。

3、 编译发布后,需要把DLL部署到GAC中,使用如下命令行部署:

gacutil –i c:\publish\ EG.EIP.BPMWebService.dll

4、 把ASP.NET Webservice的asmx文件拷贝到%ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\LAYOUTS目录

clip_image002

5、 通过disco命令,生成.wsdl文件和.disco文件

disco http://moss:8001/_layouts/BPMDocService.asmx /out:c:\moss

6、 产生2个文件BPMService.wsdl,BPMServices.disco,修改.wsdl和.disco,把这两个文件另存为BPMServicewsdl.aspx和BPMServicedisco.aspx,修改分别如下:

  • BPMService.wsdl的【如下部分】修改为BPMServicewsdl.aspx
<?xml version="1.0" encoding="utf-8"?>
……………
……………
……………
<wsdl:service name="Service">
    <wsdl:port name="ServiceSoap" binding="tns:ServiceSoap">
      <soap:address location="http://localhost:17906/MyTestWebService/Service.asmx" />
    </wsdl:port>
    <wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap12">
      <soap12:address location="http://localhost:17906/MyTestWebService/Service.asmx" />
    </wsdl:port>
  </wsdl:service>

修改为


 

  • BPMServices.disco的【如下部分】修改为BPMServicedisco.aspx
<?xml version="1.0" encoding="utf-8"?>
<discovery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/disco/">
  <contractRef ref="http://localhost:17906/MyTestWebService/Service.asmx?wsdl" docRef="http://localhost:17906/MyTestWebService/Service.asmx" xmlns="http://schemas.xmlsoap.org/disco/scl/" />
  <soap address="http://localhost:17906/MyTestWebService/Service.asmx" xmlns:q1="http://tempuri.org/" binding="q1:ServiceSoap" xmlns="http://schemas.xmlsoap.org/disco/soap/" />
  <soap address="http://localhost:17906/MyTestWebService/Service.asmx" xmlns:q2="http://tempuri.org/" binding="q2:ServiceSoap12" xmlns="http://schemas.xmlsoap.org/disco/soap/" />
</discovery>

修改为


7、 把BPMService.asmx,BPMServicewsdl.aspx和BPMServicedisco.aspx一起拷贝部署到%ProgramFiles%\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI目录下。

8、 运行效果图:

clip_image008

9、 调用此web service方法

引用此web service,由于在MOSS的站点下,不是匿名的web service站点,因此需要设置访问的账号

moss.BPMDocService doc = new moss.BPMDocService();

//设置访问的账号

doc.Credentials = new NetworkCredential("administrator","Passw0rd!", "mono");

doc.Url = "http://moss:8001/_vti_bin/BPMDocService.asmx";

doc.HelloWorld(attachment, "mono\\test");

注意:

Sharepoint2010缺省关闭了ASP.NET Webservice的访问支持,在访问以前需要把asmx文件类型的阻塞过滤删掉。操作方法Central Administration→Security→Define blocked file types→删除asmx文件类型→保存。

转载于:https://www.cnblogs.com/love007/archive/2012/11/30/2796306.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值