首页 新闻 会员 周边

delphi调用C#的Webservice出现的问题,请教高手。急。

0
悬赏园豆:100 [已关闭问题]

公司原来有delphi的系统调用delphi的webservice,现在由于某种原因,需要调用C#的webservice,可是我把webservice写好,却调用不成功。后来google了一下,上面有人说这个原因:

因为VS.Net 2005 默认是用的SoapDocumentProtocol,而Delphi 是使用的 SoapRpcProtocol,这会造成客户端传过去的字符串都变为Null。在delphi程序中Authenticate单元的初始化initialization加入InvRegistry.RegisterInvokeOptions(TypeInfo(AuthenticateSoap), ioDocument);可以解决该问题。

 

然后我肯定不能动原来delphi的程序,请问在C#中怎么改可以解决?

LCM的主页 LCM | 大侠五级 | 园豆:6876
提问于:2009-02-20 11:29
< >
分享
其他回答(1)
0

下面这篇文章讲了如何让 .net 的 web service 同时支持 RPC 和 Document SOAP,

你参考一下吧。

http://radio.weblogs.com/0105476/stories/2002/04/12/rpcAndDocumentSoapFromOnenetWebService.html

下面这个是中文的

http://msdn.microsoft.com/zh-cn/library/system.web.services.protocols.soaprpcmethodattribute(VS.80).aspx

 

<%@ WebService Language="C#" class="MyUser" %>
using System;
using System.Web.Services;
using System.Web.Services.Protocols;

public class MyUser : WebService {

[ SoapRpcMethod(Action="http://www.contoso.com/Sample",
RequestNamespace="http://www.contoso.com/Request",
RequestElementName="GetUserNameRequest",
ResponseNamespace="http://www.contoso.com/Response",
ResponseElementName="GetUserNameResponse")]
[ WebMethod(Description="Obtains the User Name") ]
public UserName GetUserName() {
string temp;
int pos;
UserName NewUser = new UserName();

// Get the full user name, including the domain name if applicable.
temp = User.Identity.Name;

// Determine whether the user is part of a domain by searching for a backslash.
pos = temp.IndexOf("\\");

// Parse out the domain name from the string, if one exists.
if (pos <= 0)
NewUser.Name = User.Identity.Name;
else {
NewUser.Name = temp.Remove(0,pos+1);
NewUser.Domain = temp.Remove(pos,temp.Length-pos);
}
return NewUser;
}

}

public class UserName {

public string Name;
public string Domain;
}
eaglet | 园豆:17139 (专家六级) | 2009-02-20 14:10
0

C#程序不需要修改,好像是Delphi加多一个引用

JeffreyChen | 园豆:255 (菜鸟二级) | 2009-02-20 15:21
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册