Custom Web Servic In MOSS 2007

Tools: Visual Studio 2008,Visual Studio 2008 Command Prompt, Sharepoint Server 2007

 

  1. Generate .disco and .wsdl files through Visual Studio 2008 Command Prompt in Visual Studio Tools

                       

 

Run command:

 

Disco http://sp2007:14908/_vti_bin/PSWebService.asmx

 

<%@ WebService Language="C#" Class="NameSpace.PSWebService, NameSpace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0c8763d1ab14ce97"  %>

 

Error occurred as below.

 

 

 

 

 

Solution: Please move PSWebService.asmx into layouts folder and try it again. It works fine. Correct screen is as below.

 

 

Two files(pswebservice.disco and pswebservice.wsdl) are stored in the path ‘C:\Temp\aa’

 

 

 

Note: You have to rename these two files(pswebservicedisco.aspx and pswebservicewsdl.aspx). You have to move these three files into ISAPI folder. The structure is below.

 

 

 

 

 

  1. These two files are not able to use and you have to change parts of content.

 

For pswebservicedisco.aspx, substitute below original for current code

 

Original Code 1:

 

<?xml version="1.0" encoding="utf-8"?>

Current Code 1:

 

<%@ Page Language="C#"   Inherits="System.Web.UI.Page"    %> <%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0,   Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint.Utilities"   %> <%@ Import Namespace="Microsoft.SharePoint"   %>

<% Response.ContentType = "text/xml";   %>

 

 

 

Original Code 2:

 

<contractRef ref="http://sp2007:14908/_layouts/pswebservice.asmx?wsdl" docRef="http://sp2007:14908/_layouts/pswebservice.asmx" xmlns="http://schemas.xmlsoap.org/disco/scl/" />

  <soap address="http://sp2007:14908/_layouts/pswebservice.asmx" xmlns:q1="http://tempuri.org/" binding="q1:PSWebServiceSoap" xmlns="http://schemas.xmlsoap.org/disco/soap/" />

  <soap address="http://sp2007:14908/_layouts/pswebservice.asmx" xmlns:q2="http://tempuri.org/" binding="q2:PSWebServiceSoap12" xmlns="http://schemas.xmlsoap.org/disco/soap/" />

 

         Current Code 2:

 

<contractRef ref=<% SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(SPWeb.OriginalBaseUrl(Request) + "?wsdl"),Response.Output); %> docRef=<%   SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(SPWeb.OriginalBaseUrl(Request)),Response.Output);   %> xmlns="http://schemas.xmlsoap.org/disco/scl/"   />

  <soap address=<%   SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(SPWeb.OriginalBaseUrl(Request)),Response.Output);   %> xmlns:q1="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/"   binding="q1:   PSWebServiceSoap" xmlns="http://schemas.xmlsoap.org/disco/soap/"   />

    <soap   address=<%   SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(SPWeb.OriginalBaseUrl(Request)),Response.Output);   %> xmlns:q2="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/"   binding="q2:PSWebServiceSoap12"   xmlns="http://schemas.xmlsoap.org/disco/soap/"   />

 

 

 

Note: You are able to copy current code from alertsdisco file below.

 

 

 

 

For pswebservicewsdl.aspx, substitute below original for current code

 

Original Code 1:

 

<?xml version="1.0" encoding="utf-8"?>

 

 

 

Current Code 1:

 

<%@ Page Language="C#"   Inherits="System.Web.UI.Page"    %> <%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0,   Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint.Utilities"   %> <%@ Import Namespace="Microsoft.SharePoint"   %>

<% Response.ContentType = "text/xml"; %>

 

Original Code 2:

 

 

 

<soap:address location="http://sp2007:14908/_layouts/pswebservice.asmx" />

 

Current Code 2:

 

<soap:address location=<%   SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(SPWeb.OriginalBaseUrl(Request)),Response.Output);   %> />

 

 

Original Code 3:

 

<soap12:address location="http://sp2007:14908/_layouts/pswebservice.asmx" />

 

Current Code 3:

 

<soap12:address location=<%   SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(SPWeb.OriginalBaseUrl(Request)),Response.Output);   %> /> 

 

 

Note: You are able to copy current code from alertswsdl file below.

 

 

 

Then you are able to deploy pswebservice web service, once done. You have to modify  spdisco.aspx file that is located in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\12\ISAPI and add the following code, specifying the .asmx file for your Web service.

 

<contractRef   ref=<% SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(spWeb.Url + "/_vti_bin/AWebService/PSWebService.asmx?wsdl"),   Response.Output); %>

docRef=<%   SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(spWeb.Url + "/_vti_bin/AWebService/PSWebService.asmx"),   Response.Output); %>

xmlns="   http://schemas.xmlsoap.org/disco/scl/ " />

<discoveryRef   ref=<% SPHttpUtility.AddQuote(SPHttpUtility.HtmlEncode(spWeb.Url + "/_vti_bin/AWebService/PSWebService.asmx?disco"),Response.Output);   %>

xmlns="http://schemas.xmlsoap.org/disco/"   />

 

 

Your web service is able to be used till now.

 

转载于:https://www.cnblogs.com/CrystalWind/p/4435064.html

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值